解决 Xcode 报 library not found for -lstdc++ 问题

在Xcode10中编译使用libstdc++的项目会遇到错误,因为Xcode10已弃用libstdc++。解决方法包括转向libc++或从Xcode9复制libstdc++库文件并正确配置。本文详细介绍了如何通过复制和配置库文件来解决此问题。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

在Xcode9上正常编译的项目,在Xcode10上编译可能会遇到如下错误:

library not found for -lstdc++.6.0.9
library not found for -lstdc++.6
library not found for -lstdc++

这是因为Xcode10彻底废弃了libstdc++,相关的库文件libstdc++.6.0.9.dylib、libstdc++.6.dylib、libstdc++.dylib、libstdc++.6.0.9.tbd、libstdc++.6.tbd、libstdc++.tbd也从Xcode10中删除了。
最好的解决办法还是尽快转到libc++开发
如果还想要继续在Xcode10上编译依赖libstdc++的项目或库,可以通过把Xcode9中的libstdc++相关库文件复制到Xcode10中即可。
在Xcode9中搜索libstdc++相关的库,可以找到四个相关的文件:

/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/usr/lib/libstdc++.6.0.9.dylib

/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/lib/libstdc++.6.0.9.tbd

/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/usr/lib/libstdc++.6.0.9.tbd

/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/usr/lib/libstdc++.6.0.9.tbd

但是只找到了libstdc++.6.0.9.dylib和libstdc++.6.0.9.tbd ,找不到libstdc++.6.dylib、libstdc++.dylib、libstdc++.6.tbd、libstdc++.tbd,前往找到的这4个路径中会就会发现libstdc++.6.dylib、libstdc++.dylib是libstdc++.6.0.9.dylib的替身,libstdc++.6.tbd、libstdc++.tbd是libstdc++.6.0.9.tbd 的替身:

在这里插入图片描述
在这里插入图片描述
所以我尝试将libstdc++.6.0.9.dylib和libstdc++.6.0.9.tbd 复制到Xcode10中,并制作libstdc++.6.dylib、libstdc++.dylib、libstdc++.6.tbd、libstdc++.tbd这四个替身文件,但是在模拟器上运行崩溃,自己制作替身的方案不可行,然后我改为了制作副本的方式成功在模拟器上运行。
下载地址点这里libstdc++.6.0.9.dylib和libstdc++.6.0.9.tbd以及制作好的副本libstdc++.6.dylib、libstdc++.dylib、libstdc++.6.tbd、libstdc++.tbd

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值