g++ 构建错误与 node-gyp 重建 Node.js 插件
g++ build errors with node-gyp rebuild for Node.js Addon
这是我的bindings.gyp文件:
{
"targets": [
{
"target_name": "hello",
"sources": [ "hello.cpp" ],
"include_dirs": [
"<!(node -e "require('nan')")"
],
"cflags" : [ "-std=c++1", "-stdlib=libc++" ],
"conditions": [
[ "OS!='win'", {
"cflags+": [ "-std=c++11" ],
"cflags_c+": [ "-std=c++11" ],
"cflags_cc+": [ "-std=c++11" ],
}],
[ "OS=='mac'", {
"xcode_settings": {
"OTHER_CPLUSPLUSFLAGS" : [ "-std=c++11", "-stdlib=libc++" ],
"OTHER_LDFLAGS": [ "-stdlib=libc++" ],
"MACOSX_DEPLOYMENT_TARGET": "10.7"
},
}],
],
}
]
}
运行时
sudo node-gyp rebuild
我收到这些错误:
make: Entering directory '/home/oleg/WebstormProjects/oresoftware/replace-line/build'
CXX(target) Release/obj.target/hello/hello.o
g++: error: unrecognized command line option ‘-std=c++1’
g++: error: unrecognized command line option ‘-stdlib=libc++’
hello.target.mk:106: recipe for target 'Release/obj.target/hello/hello.o' failed
从错误跟踪中,似乎很明显我们使用的是 g++ 而不是 gcc,而我的 g++ 版本是:
gcc version 5.4.0 20160609 (Ubuntu 5.4.0-6ubuntu1~16.04.4)
是的,我在 Ubuntu 16.04 上
有谁知道为什么会发生此错误?
你有-std=c++1
,这是一个错别字,应该是:-std=c++11
。
此外,-stdlib
是一个 clang 选项(不是 g++)。对于 g++ libstdc++,始终使用。
相关文章:
- 在 ubuntu 上安装 node js pulsar 客户端
- Node.js fs.open() 在尝试打开 4 个以上的命名管道 (FIFO) 后挂起
- 在 node.js 中将缓冲区从 C++ 转换为 UTF-8 字符串
- 使用 Node.js N-API 调用 C 函数时,不会显示预期的输出
- 如何使用 v8 本机插件将 C++ 数组交付到 Node.js
- C++ 和 node.js 之间的 RSA 加密
- node.js Nan:在函数C++调用 JavaScript 回调
- 迭代 Napi::对象属性(键)在 Node.js C++ N-API 中
- 上传大文件并解析时使用 Node.js v10.15.1 时出现致命错误
- 如何在 Node.js 中解压缩 c# 打包结构
- 使用 Node.js 调用child_process与从 C 调用子进程并创建C++绑定以从 node.js 调用
- 我们如何访问 Node.js 应用程序之外的内存?
- 我正在c 中的buidling node.js绑定
- 以有效的方式从 Node .js运行 C 或C++代码
- node.js:如何从C 模块中产生
- 如何编译 node.js for CentOS 6.10 (库问题)
- 如何使用 Node.js 开发一个侦听器来接收许多车辆跟踪数据(通过 TCP)
- 使用 N-API 将数据流式传输到 Node.js C++ 插件中
- 在node.js addon中阻止呼叫
- Node.js与C++的集成