无法在C ++中构建Node.js插件示例

时间:2017-05-31 10:38:41

标签: c++ node.js build clion node.js-addon

我尝试按照此guide中提供的示例在C ++中创建Node.js插件。

我已经用这种方式链接了node.h和v8.h库来设置我的CMakeLists.txt:

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)

我认为库已在我的CMakeList.txt中正确设置但是当我尝试在Clion中编译该文件时出现此错误:

/usr/include/nodejs/src/node.h:239: undefined reference to `v8::Isolate::GetCurrent()' 
/usr/include/nodejs/src/node.h:240: undefined reference to `v8::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 to `v8::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 to `v8::Function::SetName(v8::Local<v8::String>)'
/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()'

我做错了什么?我对C ++很陌生,所以也许我做了一些愚蠢的错误。 我忘了链接一些依赖项?

0 个答案:

没有答案