我尝试使用这个node.js文件配置和构建一个C++插件:
{
"targets": [
{
"target_name": "addon",
"sources": [ "addon.cpp" ],
"cflags": [
"-std=c++17"
]
}
]
}但是,当我运行node-gyp configure和node-gype rebuild时,我总是收到这样的消息
警告:“如果只有在-std=c++17或-std=gnu++17中可用”
构建也失败了,因为我确实依赖于这些c++17特性。我做错了什么?
发布于 2018-09-16 15:26:07
使用"cflags_cc" (而不是"cflags")可以工作。
这解决了问题。
发布于 2020-07-20 05:59:51
cflags_cc不是为我工作的,但是在VCCLCompilerTool中的设置可以工作(在VCCLCompilerTool上):
{
'targets': [
{
'target_name': 'test-napi-native',
'sources': [ 'src/test_napi.cc' ],
'include_dirs': ["<!@(node -p \"require('node-addon-api').include\")"],
'dependencies': ["<!(node -p \"require('node-addon-api').gyp\")"],
'cflags': [ '-fno-exceptions' ],
'cflags_cc': [ '-fno-exceptions' ],
'xcode_settings': {
'GCC_ENABLE_CPP_EXCEPTIONS': 'YES',
'CLANG_CXX_LIBRARY': 'libc++',
'MACOSX_DEPLOYMENT_TARGET': '10.7'
},
'msvs_settings': {
'VCCLCompilerTool': { "ExceptionHandling": 1, 'AdditionalOptions': [ '-std:c++17' ] }
}
}
]
}https://stackoverflow.com/questions/52333010
复制相似问题