5

I am compiling through node-gyp a Node.JS package written in C++. When I compile it I receive the following error: clang: error: invalid deployment target for -stdlib=libc++ (requires OS X 10.7 or later). I'm running on OSX 10.8, and I have installed the XCode Command Line Tools. This is the file used by node-gyp to compile the package:

{
  "targets": [
    {
      "target_name": "package_name",

      'type': 'executable',

      'xcode_settings': {
        'OTHER_CFLAGS': [
          "-std=c++11",
          "-stdlib=libc++"
        ],
      },

      "sources": [ "package_src.cpp" ],
    }
  ]
}

Basically it specifies the target of the compilation, the type and the flags, as well as the sources.

Any idea on how I can solve this problem?

4

2 回答 2

8

当您获得 OS X 10.8 时,clang 将尝试构建它,以便它也可以在其他较旧的 OS X 版本上运行。现在由于-stdlib=libc++需要 10.7 的最低版本,除非您通过指定明确告诉它您将使用 10.7(或更高版本)作为部署目标,否则它不会编译它

'MACOSX_DEPLOYMENT_TARGET': '10.7'

里面xcode_settings

在您的情况下,完整的设置应如下所示:

{
  "targets": [
    {
      "target_name": "package_name",

      'type': 'executable',

      'xcode_settings': {
        'MACOSX_DEPLOYMENT_TARGET': '10.7',

        'OTHER_CFLAGS': [
          "-std=c++11",
          "-stdlib=libc++"
        ],
      },

      "sources": [ "package_src.cpp" ],
    }
  ]
}
于 2014-05-26T19:30:01.837 回答
2

我不知道什么对你有用,@drewish,但这就是我让它工作的方式:

{
  "targets": [
    {
      "target_name": "package_name",

      'type': 'executable',

      'xcode_settings': {
        'OTHER_CFLAGS': [
          "-std=c++11",
      "-stdlib=libc++",
      "-mmacosx-version-min=10.7"
        ],
      },

      "sources": [ "overcpu.cpp" ],
    }
  ]
}
于 2014-05-27T07:53:15.007 回答