Invalid deployment target for -stdlib=libc++ on OSX 10.8

筅森魡賤 提交于 2021-02-07 14:36:34

问题


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?


回答1:


Whilst you got OS X 10.8 clang will try to build it so that it can be run on other older OS X versions too. Now since -stdlib=libc++ requires a minimum version of 10.7 it won't compile it unless you explicitly tell it that you'll use 10.7 (or higher) as the deployment target by specifying

'MACOSX_DEPLOYMENT_TARGET': '10.7'

inside the xcode_settings.

In your case the complete settings should look like:

{
  "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" ],
    }
  ]
}



回答2:


I don't know what worked for you, @drewish, but this is how I got it to work:

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

      'type': 'executable',

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

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


来源:https://stackoverflow.com/questions/21752172/invalid-deployment-target-for-stdlib-libc-on-osx-10-8

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!