libv8をC ++アプリに含めることができない


c ++スクリプトでlibv8-パッケージを使用しようとしました。パッケージは想定どおり/usr/lib/にインストールされていますが、g++ script.cpp -Iv8コマンドを使用してスクリプトをコンパイルしようとしても何も起こりません。


#include <v8>
#include <libv8>
#include <>
#include <>

次の行はusing namespace v8コマンドです。これを行うと、g++がエラーを返します。

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




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&);

g++ main.cpp -lv8コマンドを使用しています。


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.