Linker-Fehler mit V8-Beispielprogramm

ComFreek

Mod | @comfreek
Moderator
Guten Abend ;)

Ich habe mir soeben V8 (Revision 10346) mit MinGW (bzw. GCC) kompiliert.

Jetzt wollte ich das Beispielprogramm testen:
C++:
#include "../v8gcc/include/v8.h"

using namespace v8;

int main(int argc, char* argv[]) {

  // Create a stack-allocated handle scope.
  HandleScope handle_scope;

  // Create a new context.
  Persistent<Context> context = Context::New();
  
  // Enter the created context for compiling and
  // running the hello world script. 
  Context::Scope context_scope(context);

  // Create a string containing the JavaScript source code.
  Handle<String> source = String::New("'Hello' + ', World!'");

  // Compile the source code.
  Handle<Script> script = Script::Compile(source);
  
  // Run the script to get the result.
  Handle<Value> result = script->Run();
  
  // Dispose the persistent context.
  context.Dispose();

  // Convert the result to an ASCII string and print it.
  String::AsciiValue ascii(result);
  printf("%s\n", *ascii);
  return 0;
}
Natürlich binde ich auch die beiden Bibliotheken libv8preparser.a und libv8.a ein.
Trotzdem bekomme ich diese Linker-Fehler:
Code:
obj\Windows Debug\main.o||In function `main':|
C:\Programming\BlubTest\main.cpp|8|undefined reference to `v8::HandleScope::HandleScope()'|
C:\Programming\BlubTest\main.cpp|11|undefined reference to `v8::Context::New(v8::ExtensionConfiguration*, v8::Handle<v8::ObjectTemplate>, v8::Handle<v8::Value>)'|
C:\Programming\BlubTest\main.cpp|18|undefined reference to `v8::String::New(char const*, int)'|
C:\Programming\BlubTest\main.cpp|21|undefined reference to `v8::Script::Compile(v8::Handle<v8::String>, v8::ScriptOrigin*, v8::ScriptData*, v8::Handle<v8::String>)'|
C:\Programming\BlubTest\main.cpp|24|undefined reference to `v8::Script::Run()'|
C:\Programming\BlubTest\main.cpp|30|undefined reference to `v8::String::AsciiValue::AsciiValue(v8::Handle<v8::Value>)'|
C:\Programming\BlubTest\main.cpp|32|undefined reference to `v8::String::AsciiValue::~AsciiValue()'|
C:\Programming\BlubTest\main.cpp|32|undefined reference to `v8::HandleScope::~HandleScope()'|
C:\Programming\BlubTest\main.cpp|32|undefined reference to `v8::HandleScope::~HandleScope()'|
obj\Windows Debug\main.o||In function `Scope':|
C:\Programming\BlubTest\..\v8gcc\include\v8.h|3522|undefined reference to `v8::Context::Enter()'|
obj\Windows Debug\main.o||In function `~Scope':|
C:\Programming\BlubTest\..\v8gcc\include\v8.h|3524|undefined reference to `v8::Context::Exit()'|
obj\Windows Debug\main.o:C:\Programming\BlubTest\..\v8gcc\include\v8.h|3922|undefined reference to `v8::V8::DisposeGlobal(v8::internal::Object**)'|
||=== Build finished: 12 errors, 0 warnings ===|

IDE ist Code::Blocks, Betriebssystem Windows Vista 32-bit.

Any ideas?
Vielen Dank im Voraus!
 
Okay, ich habe es mit folgendem Befehl hinbekommen:
Code:
C:\Programming\BlubTest>g++ -I ../v8gcc/include main.cpp -L ../v8gcc -o main -l v8 -l ws
2_32 -l winmm

Jetzt fragt sich noch, wie ich das in Code::Blocks automatisch so hinbekomme.
 
Hi.
Okay, ich habe es mit folgendem Befehl hinbekommen:
Code:
C:\Programming\BlubTest>g++ -I ../v8gcc/include main.cpp -L ../v8gcc -o main -l v8 -l ws
2_32 -l winmm

Jetzt fragt sich noch, wie ich das in Code::Blocks automatisch so hinbekomme.
../v8gcc/include main.cpp als zusätzliches Include Verzeichnis einstellen (besser absolute Pfade verwenden, sonst stimmt es nicht wenn der Compiler nicht im gleichen Pfad wie main.cpp gestartet wird).

../v8gcc als zusätzl. Lib Verzeichnis einstellen.

v8 als zusätzl. Bibliothek hinzufügen.

Gruß
 
Danke, jetzt hat es funktioniert!


Für Suchende:
Bei Project->Build options... rechts im Tab Linker Settings mittels Add-Button folgende Bibliotheken hinzufügen:
  • libv8.a
  • libws2_32.a (ohne Pfadangabe)
  • libwinmm.a (ohne Pfadangabe)
 
Zurück