ld:找不到-lstdc++.6 的库
ld: library not found for -lstdc++.6
更新 Xcode 版本到 10.0 beta 后开始出现 "ld: library not found for -lstdc++.6" 错误。相同的代码在 Xcode 9.2
中运行良好
还将 macOS 更新到 10.13.5
定位 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)
来源:Release Notes of XCode Beta 2
旁注:
您需要登录才能访问该页面。
Link 可能会在下一个测试版中中断(URL 更改),但它在 Developers/Download
部分
XCode 10 正式发布 release note,还是这样:
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)
如上所述,lstdc++ 已从 Xcode10 中删除。要解决此问题,
转到 Target -> BuildPhases -> Link Binary With Libraries
搜索 lstdc++ 并将其删除。
现在您可能会在使用上述 "lstdc++" 库的某些框架中遇到错误。现在,您要么必须更新这些框架,要么将其删除,以便 Xcode 可以成功构建它。
- 如果您使用外部 Makefile 构建 C++ 库,请添加
CXXFLAGS += -stdlib=libc++
您的外部库 Makefile 并删除了 -stdlib=stdlibc++
的实例
- 如果没有,忽略上面的步骤,直接进入Project>Target>Link Binary with libraries>
- 删除 (-) libstdc++.6.0.9.tbd
- 添加 (+) libc++.tbd
只需转到构建设置,Link 带有库的二进制文件,然后删除 this.It 解决了我的问题。
快速解决方案是将所有 libstdc++.* 文件从旧 Xcode(9.4) 复制到新 Xcode(10.x)
对于设备:
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/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/usr/lib/libstdc++.* /Applications/Xcode10.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/usr/lib/
我在尝试 make install
时失败了。相反,我 运行 make install -stdlib=libc++
成功了。
我试图编译 C 程序并得到 ld: library not found for -lc++
由于提到的弃用以及告诉 C++ 从旧 mac sdk 读取的解决方法 /Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk
# adjust your llvm and CLT include paths to match your setup
export CPLUS_INCLUDE_PATH=/usr/local/opt/llvm/include/c++/v1:/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/include
# then set correct var for compiler lib
export LIBRARY_PATH=$LIBRARY_PATH:/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/lib
在 fixing-cpp-compilation-bugs-for-the-mac-os-catalina-upgrade
的演练很不错
更新 Xcode 版本到 10.0 beta 后开始出现 "ld: library not found for -lstdc++.6" 错误。相同的代码在 Xcode 9.2
中运行良好还将 macOS 更新到 10.13.5
定位 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)
来源:Release Notes of XCode Beta 2
旁注:
您需要登录才能访问该页面。
Link 可能会在下一个测试版中中断(URL 更改),但它在 Developers/Download
XCode 10 正式发布 release note,还是这样:
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)
如上所述,lstdc++ 已从 Xcode10 中删除。要解决此问题,
转到 Target -> BuildPhases -> Link Binary With Libraries
搜索 lstdc++ 并将其删除。
现在您可能会在使用上述 "lstdc++" 库的某些框架中遇到错误。现在,您要么必须更新这些框架,要么将其删除,以便 Xcode 可以成功构建它。
- 如果您使用外部 Makefile 构建 C++ 库,请添加
CXXFLAGS += -stdlib=libc++
您的外部库 Makefile 并删除了 -stdlib=stdlibc++
- 如果没有,忽略上面的步骤,直接进入Project>Target>Link Binary with libraries>
- 删除 (-) libstdc++.6.0.9.tbd
- 添加 (+) libc++.tbd
只需转到构建设置,Link 带有库的二进制文件,然后删除 this.It 解决了我的问题。
快速解决方案是将所有 libstdc++.* 文件从旧 Xcode(9.4) 复制到新 Xcode(10.x)
对于设备:
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/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/usr/lib/libstdc++.* /Applications/Xcode10.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/usr/lib/
我在尝试 make install
时失败了。相反,我 运行 make install -stdlib=libc++
成功了。
我试图编译 C 程序并得到 ld: library not found for -lc++
由于提到的弃用以及告诉 C++ 从旧 mac sdk 读取的解决方法 /Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk
# adjust your llvm and CLT include paths to match your setup
export CPLUS_INCLUDE_PATH=/usr/local/opt/llvm/include/c++/v1:/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/include
# then set correct var for compiler lib
export LIBRARY_PATH=$LIBRARY_PATH:/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/lib
在 fixing-cpp-compilation-bugs-for-the-mac-os-catalina-upgrade
的演练很不错