0

I'm strugling to compile a really small example with V8..

cpp program is this:

#include "v8.h"

int main()
{
     v8::HandleScope handle_scope;

     return 0;
}

Compile line: g++ -I/home/lterje/git/tengine/Externals/v8/include /home/lterje/git/tengine/Externals/v8/out/ia32.release/obj.target/tools/gyp/libv8_snapshot.a test.cpp -o test -lpthread

Error I'm getting:

/tmp/ccHYtJuE.o: In function `main':
test.cpp:(.text+0x11): undefined reference to `v8::HandleScope::HandleScope()'
test.cpp:(.text+0x22): undefined reference to `v8::HandleScope::~HandleScope()'
collect2: error: ld returned 1 exit status

What exactly is the difference between the base, snapshot and no snapshot library files? I've tried linking with each of them, but none of them works :/

12
  • how do you link againest these libraries? do you have a CMakeLists.txt file?can you include that Commented Feb 25, 2013 at 16:21
  • developers.google.com/v8/get_started If you look at the bottom there and point 3, it seams like you can just give the full path like they do there? Commented Feb 25, 2013 at 16:30
  • You need to download and install the v8 libraries and if you installed them on a defuault path, like /usr/local/lib etc... then it sufficies to link againest them using -llibv8 or -lv8 or something. did you do that? Commented Feb 25, 2013 at 16:35
  • as you see from the compile line I've downloaded it into a folder and I've built it with gyp.. they're not linking to v8 on the link I posted above? I don't even think libv8 exists anymore.. its libv8_base.a , libv8_snapshot.a and libv8_nosnapshot.a as I mentioned above.. have you built it before and if so, what is the line you are building with? Commented Feb 25, 2013 at 16:40
  • 1
    You're not following the instructions. The .a files need to go after your source files on the command line. Commented Feb 25, 2013 at 17:24

2 Answers 2

2

first I have to say sorry for my poor english. I have just link the .a file to my own project. There's ld error because of the dependencies of the libv8_snapshot.a is not been given.

This is my compile statement:

g++ -o xxxxx -I ~v8/out/native/obj.target/tools/gyp/libv8_{base.native,snapshot}.a ~v8/out/native/obj.target/third_party/icu/libicu{data,i18n,snapshot}.a ~v8/out/native/obj.target/icudata/third_party/icu/linux/icudt46_dat.o -lrt -lpthread

I think that the libv8_base.native.a libv8_snapshot.a is dependend on icu and icudt46 files and thereis some functions about unix clock_time is dependend on "rt", so add "-lrt"

Hope helpful for you all~ As a Chinese,sorry for my english.

Sign up to request clarification or add additional context in comments.

Comments

0

Compile line:
g++ -I/home/lterje/git/tengine/Externals/v8/include /home/lterje/git/tengine/Externals/v8/out/ia32.release/obj.target/tools/gyp/libv8_snapshot.a test.cpp -o test -lpthread

This link line is incorrect. Try this instead:

g++ -I/home/lterje/git/tengine/Externals/v8/include \
  test.cpp -o test \
  /home/.../obj.target/tools/gyp/libv8_snapshot.a \
  -lpthread

Read this to understand why the order matters.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.