include — Невозможно скомпилировать простую программу на C ++

Я скачал следующую библиотеку C ++ (коммерческий безголовый браузер) http://wiki.awesomium.com/. Я распаковал его, и структура каталогов выглядит следующим образом:

/opt/awesomium_v1.7.2_sdk_linux64/bin

содержит файлы:

awesomium_pak_utility  awesomium_process  awesomium_sample_webflow  libawesomium-1-7.so.2.0

Следующий путь включает включаемые файлы:

/opt/awesomium_v1.7.2_sdk_linux64/include/Awesomium# ls
BitmapSurface.h  DataSource.h  JSValue.h      ResourceInterceptor.h  WebConfig.h         WebKeyboardEvent.h  WebSession.h      WebTouchEvent.h  WebViewListener.h
ChildProcess.h   JSArray.h     Platform.h     STLHelpers.h           WebCore.h           WebMenuItem.h       WebStringArray.h  WebURL.h
DataPak.h        JSObject.h    PrintConfig.h  Surface.h              WebKeyboardCodes.h  WebPreferences.h    WebString.h       WebView.h

Итак, в пакет включен очень простой пример демонстрационного кода, который я пытаюсь скомпилировать:

/opt/awesomium_v1.7.2_sdk_linux64/samples/hello# cat main.cc
/**
* This is a simple "Hello World!" example of using Awesomium.
*
* It loads a page and saves a rendered bitmap of it to a JPEG.
*
* Procedure:
* -- Create the WebCore singleton
* -- Create a new WebView and request for it to load a URL.
* -- Wait for the WebView to finish loading.
* -- Retrieve the BitmapSurface from the WebView.
* -- Save the BitmapSurface to 'result.jpg'.
* -- Clean up.
*/

// Various included headers
#include <Awesomium/WebCore.h>
#include <Awesomium/BitmapSurface.h>
#include <Awesomium/STLHelpers.h>
#include <iostream>
#if defined(__WIN32__) || defined(_WIN32)
#include <windows.h>
#elif defined(__APPLE__)
#include <unistd.h>
#endif

// Various macro definitions
#define WIDTH   800
#define HEIGHT  600
#define URL     "http://www.google.com"
using namespace Awesomium;

// Forward declaration of our update function
void Update(int sleep_ms);

// Our main program
int main() {
// Create the WebCore singleton with default configuration
WebCore* web_core = WebCore::Initialize(WebConfig());

// Create a new WebView instance with a certain width and height, using the
// WebCore we just created
WebView* view = web_core->CreateWebView(WIDTH, HEIGHT);

// Load a certain URL into our WebView instance
WebURL url(WSLit(URL));
view->LoadURL(url);

std::cout << "Page is now loading..." << std::endl;;

// Wait for our WebView to finish loading
while (view->IsLoading())
Update(50);

std::cout << "Page has finished loading." << std::endl;

std::cout << "Page title is: " << view->title() << std::endl;

// Update once more a little longer to allow scripts and plugins
// to finish loading on the page.
Update(300);

// Get the WebView's rendering Surface. The default Surface is of
// type 'BitmapSurface', we must cast it before we can use it.
BitmapSurface* surface = (BitmapSurface*)view->surface();

// Make sure our surface is not NULL-- it may be NULL if the WebView
// process has crashed.
if (surface != NULL) {
// Save our BitmapSurface to a JPEG image
surface->SaveToJPEG(WSLit("./result.jpg"));

std::cout << "Saved a render of the page to 'result.jpg'." << std::endl;

// Open up the saved JPEG
#if defined(__WIN32__) || defined(_WIN32)
system("start result.jpg");
#elif defined(__APPLE__)
system("open result.jpg");
#endif
}

// Destroy our WebView instance
view->Destroy();

// Update once more before we shutdown for good measure
Update(100);

// Destroy our WebCore instance
WebCore::Shutdown();

return 0;
}

void Update(int sleep_ms) {
// Sleep a specified amount
#if defined(__WIN32__) || defined(_WIN32)
Sleep(sleep_ms);
#elif defined(__APPLE__)
usleep(sleep_ms * 1000);
#endif

// You must call WebCore::update periodically
// during the lifetime of your application.
WebCore::instance()->Update();
}

Я пытаюсь скомпилировать его следующим образом:

gcc -o main -Wall -I/opt/awesomium_v1.7.2_sdk_linux64/include/Awesomium/ -L/opt/awesomium_v1.7.2_sdk_linux64/bin -lawesomium-1-7 main.cc

Тем не менее, я получаю следующее сообщение об ошибке на консоли:

/opt/awesomium_v1.7.2_sdk_linux64/samples/hello# gcc -o main -Wall -I/opt/awesomium_v1.7.2_sdk_linux64/include/Awesomium/ -L/opt/awesomium_v1.7.2_sdk_linux64/bin -lawesomium-1-7 main.cc
main.cc:16:31: error: Awesomium/WebCore.h: No such file or directory
main.cc:17:37: error: Awesomium/BitmapSurface.h: No such file or directory
main.cc:18:34: error: Awesomium/STLHelpers.h: No such file or directory
main.cc:31: error: ‘Awesomium’ is not a namespace-name
main.cc:31: error: expected namespace-name before ‘;’ token
main.cc: In function ‘int main()’:
main.cc:39: error: ‘WebCore’ was not declared in this scope
main.cc:39: error: ‘web_core’ was not declared in this scope
main.cc:39: error: ‘WebCore’ is not a class or namespace
main.cc:39: error: ‘WebConfig’ was not declared in this scope
main.cc:43: error: ‘WebView’ was not declared in this scope
main.cc:43: error: ‘view’ was not declared in this scope
main.cc:46: error: ‘WebURL’ was not declared in this scope
main.cc:46: error: expected ‘;’ before ‘url’
main.cc:47: error: ‘url’ was not declared in this scope
main.cc:65: error: ‘BitmapSurface’ was not declared in this scope
main.cc:65: error: ‘surface’ was not declared in this scope
main.cc:65: error: expected primary-expression before ‘)’ token
main.cc:65: error: expected ‘;’ before ‘view’
main.cc:71: error: ‘WSLit’ was not declared in this scope
main.cc:90: error: ‘WebCore’ is not a class or namespace
main.cc: In function ‘void Update(int)’:
main.cc:105: error: ‘WebCore’ has not been declared

Что я делаю неправильно?

1

Решение

Ваш путь включения кажется неверным. Попробуй скомпилировать с

gcc -o main -Wall -I/opt/awesomium_v1.7.2_sdk_linux64/include -L/opt/awesomium_v1.7.2_sdk_linux64/bin -lawesomium-1-7 main.cc
0

Другие решения

Других решений пока нет …

По вопросам рекламы [email protected]