编译报错
ld: library not found for -lstdc++.6.0.9
报错原因:Xcode升级到Xcode10.0后,由于去掉陈旧的libstdc++库替换为libc++,libc++相对是苹果最新版的C++库,经过优化并全面支持C++11
到xcode9下将 libstdc++、libstdc++.6、libstdc++6.0.9拷贝到Xcode的如下目录:
1.真机环境:/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/usr/lib/
2.模拟器环境:/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/usr/lib/
之后运行报错
dyld: Library not loaded: /usr/lib/libstdc++.6.dylib
Referenced from: /Users/Aaron/Library/Developer/CoreSimulator/Devices/45300C0A-A60C-4931-A41B-504938E58091/data/Containers/Bundle/Application/8E8315C8-F72B-4BA4-9237-6218EF416F29/MobileOffice_iphone.app/MobileOffice_iphone
Reason: no suitable image found. Did find:
/usr/lib/libstdc++.6.dylib: mach-o, but not built for iOS simulator
这里还需要拷贝旧Xcode中的/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并改名为libstdc++.6.dylib后粘贴到新Xcode同样的位置。(注意在/Profiles/Runtimes/iOS.simruntime这里时需要右键显示包内容)。
网友评论