代码之家  ›  专栏  ›  技术社区  ›  user1511417

节点gyp忽略(c++17)cflag

  •  0
  • user1511417  · 技术社区  · 6 年前

    我尝试配置和构建节点.jsC++插件 绑定.gyp文件:

    { 
      "targets": [
        {
          "target_name": "addon",
          "sources": [ "addon.cpp" ],
          "cflags": [
            "-std=c++17"
          ]          
        }
      ]
    }
    

    但当我跑的时候 node-gyp configure node-gype rebuild 我总是收到这样的信息

    1 回复  |  直到 6 年前
        1
  •  3
  •   Chris    4 年前

    cflags cflags\u cc对我不起作用,但通过VCCLCompilerTool中的设置,它可以工作(在Windows上):

    {
      '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' ] }
          }
        }
      ]
    }
    
        2
  •  2
  •   user1511417    6 年前

    使用 "cflags_cc" (代替 "cflags" )工作。