xcode ld:找不到 -lstdc++.6 的库

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/51060596/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 10:41:26  来源:igfitidea点击:

ld: library not found for -lstdc++.6

iosxcodemacosxcode10

提问by vks

After updating Xcode Version to 10.0 beta start getting "ld: library not found for -lstdc++.6" error. same code working fine in Xcode 9.2

将 Xcode 版本更新到 10.0 beta 后,开始出现“ld: library not found for -lstdc++.6”错误。相同的代码在 Xcode 9.2 中工作正常

Also updated macOS to 10.13.5

还将 macOS 更新至 10.13.5

采纳答案by Shamsher Singh

The quick solution is to copy all libstdc++.* file from old Xcode(9.4) to new Xcode(10.x)

快速解决方案是将所有 libstdc++.* 文件从旧的 Xcode(9.4) 复制到新的 Xcode(10.x)

For device :

对于设备:

cp /Applications/Xcode9.4.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/usr/lib/libstdc++.* /Applications/Xcode10.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/usr/lib/

cp /Applications/Xcode9.4.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/usr/lib/libstdc++.* /Applications/Xcode10.app/Contents/Developer/Platforms/iPhoneOS。平台/开发人员/SDKs/iPhoneOS.sdk/usr/lib/

For Simulator :

对于模拟器:

cp /Applications/Xcode9.4.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/usr/lib/libstdc++.* /Applications/Xcode10.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/usr/lib/

cp /Applications/Xcode9.4.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/usr/lib/libstdc++.* /Applications/Xcode10.app/Contents/Developer/Platforms/iPhoneSimulator。平台/开发人员/SDKs/iPhoneSimulator.sdk/usr/lib/

回答by Larme

You'll have this issue when targeting iOS App. It's stated in the Release note:

定位 iOS 应用程序时,您会遇到此问题。它在发行说明中说明:

Deprecation Notices:

Building with libstdc++ was deprecated with Xcode 8 and is not supported in Xcode 10 when targeting iOS. C++ projects must now migrate to libc++ and are recommended to set a deployment target of iOS 7 or later. Besides changing the C++ Standard Library build setting, developers should audit hard-coded linker flags and target dependencies to remove references to libstdc++ (including -lstdc++, -lstdc++.6.0.9, libstdc++.6.0.9.tbd, and libstdc++.6.0.9.dylib). Project dependencies such as static archives that were built against libstdc++ will also need to be rebuilt against libc++. (40885260)

弃用通知

使用 libstdc++ 构建在 Xcode 8 中已被弃用,并且在面向 iOS 时在 Xcode 10 中不受支持。C++ 项目现在必须迁移到 libc++,建议设置为 iOS 7 或更高版本的部署目标。除了更改 C++ 标准库构建设置外,开发人员还应审核硬编码的链接器标志和目标依赖项,以删除对 libstdc++(包括 -lstdc++、-lstdc++.6.0.9、libstdc++.6.0.9.tbd 和 libstdc++.6.0 的引用。 9.dylib)。项目依赖项(例如针对 libstdc++ 构建的静态档案)也需要针对 libc++ 重建。(40885260)

Source: Release Notes of XCode Beta 2

来源:XCode Beta 2 发行说明

Side Note:
You need to be logged to access the page.
Link might break in next beta release (URLs change), but it's in the part Developers/Download

旁注:
您需要登录才能访问该页面。
链接可能会在下一个 beta 版本中断开(URL 更改),但它位于开发人员/下载部分

XCode 10 being officially released with its release note, it's still as such:

XCode 10 与其发行说明一起正式发布,它仍然是这样的:

Building with libstdc++ was deprecated with Xcode 8 and is not supported in Xcode 10 when targeting iOS. C++ projects must now migrate to libc++ and are recommended to set a deployment target of macOS 10.9 or later, or iOS 7 or later. Besides changing the C++ Standard Library build setting, developers should audit hard-coded linker flags and target dependencies to remove references to libstdc++ (including -lstdc++, -lstdc++.6.0.9, libstdc++.6.0.9.tbd, and libstdc++.6.0.9.dylib). Project dependencies such as static archives that were built against libstdc++ will also need to be rebuilt against libc++. (40885260)

使用 libstdc++ 构建在 Xcode 8 中已被弃用,并且在面向 iOS 时在 Xcode 10 中不受支持。C++ 项目现在必须迁移到 libc++,建议将部署目标设置为 macOS 10.9 或更高版本,或 iOS 7 或更高版本。除了更改 C++ 标准库构建设置外,开发人员还应审核硬编码的链接器标志和目标依赖项,以删除对 libstdc++(包括 -lstdc++、-lstdc++.6.0.9、libstdc++.6.0.9.tbd 和 libstdc++.6.0 的引用。 9.dylib)。项目依赖项(例如针对 libstdc++ 构建的静态档案)也需要针对 libc++ 重建。(40885260)

回答by rajtharan-g

As said above lstdc++ is removed from Xcode 10. To fix this,

如上所述,lstdc++ 已从 Xcode 10 中删除。要解决此问题,

  1. Go to Target -> BuildPhases -> Link Binary With Libraries

  2. Search for lstdc++ and remove it.

  3. Now you might get error in some framework which uses the above said "lstdc++" library. Now either you have to update those framework or remove it so that Xcode can build it successfully.

  1. 转到目标 -> BuildPhases -> 将二进制文件与库链接

  2. 搜索 lstdc++ 并将其删除。

  3. 现在,您可能会在使用上述“lstdc++”库的某些框架中遇到错误。现在,您要么必须更新这些框架,要么将其删除,以便 Xcode 可以成功构建它。

回答by ir2pid

  1. If you are using an external Makefile for building C++ libraries, add
  1. 如果您使用外部 Makefile 来构建 C++ 库,请添加

CXXFLAGS += -stdlib=libc++your external library Makefile and removed instances of -stdlib=stdlibc++

CXXFLAGS += -stdlib=libc++您的外部库 Makefile 和已删除的实例 -stdlib=stdlibc++

  1. If not, ignore the above step, just go to Project>Target>Link Binary with libraries>
    • Remove (-) libstdc++.6.0.9.tbd
    • Add (+) libc++.tbd
  1. 如果没有,请忽略上面的步骤,只需转到 Project>Target>Link Binary with libraries>
    • 删除 (-) libstdc++.6.0.9.tbd
    • 添加 (+) libc++.tbd

回答by user394430

This was failing for me when trying to do a make install. Instead, I ran make install -stdlib=libc++, which did the trick.

尝试执行make install. 相反,我跑了make install -stdlib=libc++,这成功了。

回答by user1828845

Simply go to build settings, Link binary with libraries and there remove this.It resolved my issue.

只需转到构建设置,将二进制文件与库链接,然后删除它。它解决了我的问题。