Wednesday 31 May 2017

Cannot build Node.js addon example in C++

I'm trying to create a Node.js addon in C++ following the example provided in this guide.

I've linked the node.h and v8.h libraries setting my CMakeLists.txt in this way:

cmake_minimum_required(VERSION 3.6) project(node___C__)

set(CMAKE_CXX_STANDARD 11)

set(SOURCE_FILES main.cpp) add_executable(node___C__ ${SOURCE_FILES}) include_directories(/usr/include/nodejs/src) include_directories(/usr/include/nodejs/deps/v8/include)

I think libraries are correctly setted in my CMakeList.txt but when I try to compile the file in Clion I get this error:

/usr/include/nodejs/src/node.h:239: undefined reference to v8::Isolate::GetCurrent()' /usr/include/nodejs/src/node.h:240: undefined reference tov8::HandleScope::HandleScope(v8::Isolate*)' /usr/include/nodejs/src/node.h:242: undefined reference to v8::FunctionTemplate::New(v8::Isolate*, void (*)(v8::FunctionCallbackInfo<v8::Value> const&), v8::Local<v8::Value>, v8::Local<v8::Signature>, int)' /usr/include/nodejs/src/node.h:243: undefined reference tov8::FunctionTemplate::GetFunction()' /usr/include/nodejs/src/node.h:244: undefined reference to v8::String::NewFromUtf8(v8::Isolate*, char const*, v8::String::NewStringType, int)' /usr/include/nodejs/src/node.h:245: undefined reference tov8::Function::SetName(v8::Local)' /usr/include/nodejs/src/node.h:246: undefined reference to v8::Object::Set(v8::Local<v8::Value>, v8::Local<v8::Value>)' /usr/include/nodejs/src/node.h:240: undefined reference to v8::HandleScope::~HandleScope()' /usr/include/nodejs/src/node.h:240: undefined reference to `v8::HandleScope::~HandleScope()'

What I'm doing wrong?



via Jack

No comments:

Post a Comment