Search code examples
c++node.jsmodulev8

Compiling NodeJs Module against V8


I know this has been asked a couple of times recently, however I'm getting a linker error when trying to compile the simplest module example on Ubuntu 13.04

Inspired by the v8 developer website, I downloaded, compiled and installed nodejs and v8 from source.

I then proceeded to attempt to compile a simple v8 example:

g++ hello_world.cc -o hello_world -Iinclude out/native/obj.target/tools/gyp/libv8_snapshot.a -lpthread

The linker errors that I am getting are:

undefined reference to `v8::HandleScope::~HandleScope()'

along with others within the v8 namespace.

Does anybody have any clue as to what library I am missing? I have the node.h and v8.h header files included in my path. Thanks in advance for your help.


Solution

  • You should use node-gyp tool to build native addons.

    npm install -g node-gyp
    

    Add a binding.gyp file in addon's root directory. Check here for an example https://github.com/TooTallNate/node-gyp#the-bindinggyp-file

    And then -

    node-gyp configure
    
    node-gyp build