我正在工作的一个项目,使用立体相机的深度相机泽德,以检索距离的障碍。它的SDK是用C++编写的,它需要CUDA 6.5。但是,我必须将这个程序与项目的另一个部分集成起来,它是用nodejs编写的。因此,我决定将ZED代码编译为一个节点模块。我经历过节点addon教程。现在我已经编写了接口,但是在尝试使用命令“Now配置构建”构建项目后,我得到了以下错误。 'zed‘模块似乎没有构建。,我不知道这个错误是什么,到目前为止我还没有搜索到任何东西。有人能给我指路吗?谢谢。
gyp info it worked if it ends with ok
gyp info using node-gyp@2.0.2
gyp info using node@0.12.7 | linux | x64
gyp info spawn python2
gyp info spawn args [ '/usr/lib/node_modules/node-gyp/gyp/gyp_main.py',
gyp info spawn args 'binding.gyp',
gyp info spawn args '-f',
gyp info spawn args 'make',
gyp info spawn args '-I',
gyp info spawn args '/Path/to/My/Project/DepthViewer/node_zed_module/build/config.gypi',
gyp info spawn args '-I',
gyp info spawn args '/usr/lib/node_modules/node-gyp/addon.gypi',
gyp info spawn args '-I',
gyp info spawn args '/home/joe/.node-gyp/0.12.7/common.gypi',
gyp info spawn args '-Dlibrary=shared_library',
gyp info spawn args '-Dvisibility=default',
gyp info spawn args '-Dnode_root_dir=/home/joe/.node-gyp/0.12.7',
gyp info spawn args '-Dnode_gyp_dir=/usr/lib/node_modules/node-gyp',
gyp info spawn args '-Dmodule_root_dir=/Path/to/My/Project/DepthViewer/node_zed_module',
gyp info spawn args '--depth=.',
gyp info spawn args '--no-parallel',
gyp info spawn args '--generator-output',
gyp info spawn args 'build',
gyp info spawn args '-Goutput_dir=.' ]
gyp info spawn make
gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
make: Entering directory `/Path/to/My/Project/DepthViewer/node_zed_module/build'
CXX(target) Release/obj.target/zed/../src/main.o
/bin/sh: 1: -DNODE_GYP_MODULE_NAME=zed: not found
make: [Release/obj.target/zed/../src/main.o] Error 127 (ignored)
SOLINK_MODULE(target) Release/obj.target/zed.node
/bin/sh: 1: -shared: not found
make: [Release/obj.target/zed.node] Error 127 (ignored)
COPY Release/zed.node
cp: cannot stat ‘Release/obj.target/zed.node’: No such file or directory
make: *** [Release/zed.node] Error 1
make: Leaving directory `/Path/to/My/Project/DepthViewer/node_zed_module/build'
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack at ChildProcess.onExit (/usr/lib/node_modules/node-gyp/lib/build.js:269:23)
gyp ERR! stack at ChildProcess.emit (events.js:110:17)
gyp ERR! stack at Process.ChildProcess._handle.onexit (child_process.js:1074:12)
gyp ERR! System Linux 3.13.0-58-generic
gyp ERR! command "node" "/usr/bin/node-gyp" "configure" "build"
gyp ERR! cwd /Path/to/My/Project/DepthViewer/node_zed_module
gyp ERR! node -v v0.12.7
gyp ERR! node-gyp -v v2.0.2
gyp ERR! not ok 这是我的binding.gyp:
{
"targets": [
{
"target_name": "zed",
"sources": [
"../src/main.cpp",
],
"include_dirs": [
"/usr/local/zed/include/",
"/usr/local/cuda-6.5/include/",
"../include/"
],
}
]
}这是我的package.json:
{
"name": "zed_depth_viewer",
"version": "0.0.0",
"description": "Measure depth with zed sdk",
"main": "zed_depth.js",
"private": true,
"gypfile": true,
"dependencies": {
"bindings": "~1.2.1"
}
}下面是我与节点的接口:(刚刚开始测试,“initProgram”作为项目的“主”)
void node_main_handle(const FunctionCallbackInfo<Value>& args) {
Isolate* isolate = Isolate::GetCurrent();
HandleScope scope(isolate);
Local<FunctionTemplate> tpl = FunctionTemplate::New(isolate, initProgram);
Local<Function> fn = tpl->GetFunction();
// omit this to make it anonymous
fn->SetName(String::NewFromUtf8(isolate, "initProgram"));
args.GetReturnValue().Set(fn);
}
void Init(Handle<Object> exports, Handle<Object> module)
{
NODE_SET_METHOD(module, "exports", node_main_handle);
}
NODE_MODULE(zed, Init) 使用此模块的一个示例应该是:
var zed = require('bindings')('zed'); //zed.node will be in './build/Release/'
var func = zed();
func();不确定这是否有效,还没有进行测试。我是nodejs的新手。
发布于 2015-07-27 06:31:15
从/bin/sh: 1: -DNODE_GYP_MODULE_NAME=zed: not found行看来,编译器是找不到的(它应该类似于/usr/bin/g++,而不是/bin/sh)。如果您希望将自定义标志传递给gyp,或者如果您想要一个特定的编译器,则您的gyp文件应该如下所示:
{
'make_global_settings': [
['CXX','/usr/bin/clang++-3.5'],
['LINK','/usr/bin/clang++-3.5'],
],
"targets": [
{
"target_name": "zed",
"sources": [
"../src/main.cpp",
],
"include_dirs": [
"/usr/local/zed/include/",
"/usr/local/cuda-6.5/include/",
"../include/"
],
"link_settings": {
"libraries": [ // For compiler
"-requiredlibs",
],
"ldflags": [ // For linker
"-L</path/to/libs",
"-Wl,-rpath,path/to/libs",
]
},
"cflags": [
"-std=c++11"
],
}
]
}上面的gyp文件使用clang (而不是g++)编译和链接,并为创建的共享库设置正确的rpath,这样每次使用绑定时都不需要导出库路径!
有关更多信息,这篇文章可能是有用的!
https://stackoverflow.com/questions/31641089
复制相似问题