I was trying to use the libv8- package in my c++ script. The package is installed in /usr/lib/ as supposed but if I try to compile my script using g++ script.cpp -Iv8 command, nothing happens.

What should be in the script's header so I could use the library? This is what I've tried:

#include <v8>
#include <libv8>
#include <libv8.so>
#include <v8.so>

On the next line was using namespace v8 command. When I do this, g++ returns an error:

index.cpp:1:20: fatal error: libv8.so: No such file or directory
 #include <libv8.so>
compilation terminated.

Or something like that. I have even tried to compile it without the header but g++ didn't like it.

Is it possible to use the library this way? And how? Thank you, m93a

EDIT: After installing libv8-dev (or libv8-3.14-dev, I've tried both) compiler throws:

index.cpp: In function ‘int main(int, char**)’:
index.cpp:10:35: error: no matching function for call to ‘v8::HandleScope::HandleScope(v8::Isolate*&)’
   HandleScope handle_scope(isolate);
index.cpp:10:35: note: candidates are:
In file included from index.cpp:1:0:
/usr/include/v8.h:473:3: note: v8::HandleScope::HandleScope(const v8::HandleScope&)
   HandleScope(const HandleScope&);

And so on... (it's too long and still saying something's not found)
I'm using g++ main.cpp -lv8 command.

  • Could add you main.cpp code to the question? if you still have it, now 6years ago.
    – user.dz
    Nov 3, 2019 at 10:56

1 Answer 1


To use a library in a program you are writing (in C/C++ at least), you need not only the compiled library (the .so - shared object file) but also a header file, which describes the functions and data structures used by the library.

Header files are not usually installed by default. They are usually found in a package called libwhatever-dev, in this case libv8-dev which needs to be installed.

You then need the line:

#include <v8.h>

to include the V8 headers. When compiling, you'll also need to tell g++ to link with the v8 library (-lv8). V8 is a fairly complex beast, and it would probably be wise to find a working example or tutorial to see how they compile it.

Finally, a note on terminology: a script normally refers to code which is executed directly from the readable text form by an interpreter (such as python), whereas this has to be first compiled before it can be run.

  • Thanks for your help! Yeah, that -Iv8 was my fault. I've tried your solution - still not working - details at the bottom of my question. PS: If it's not a script, what is it? Just code?
    – m93a
    Nov 18, 2013 at 16:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.