解決Xcode10 library not found for -lstdc++ 找不到問題

在Xcode9上正常編譯的項(xiàng)目,在Xcode10上編譯可能會(huì)遇到如下錯(cuò)誤:

librarynotfoundfor-lstdc++.6.0.9librarynotfoundfor-lstdc++.6librarynotfoundfor-lstdc++

這是因?yàn)閄code10徹底廢棄了libstdc++,相關(guān)的庫文件libstdc++.6.0.9.dylib、libstdc++.6.dylib、libstdc++.dylib、libstdc++.6.0.9.tbd、libstdc++.6.tbd、libstdc++.tbd也從Xcode10中刪除了。

最好的解決辦法還是盡快轉(zhuǎn)到libc++開發(fā)

如果還想要繼續(xù)在Xcode10上編譯依賴libstdc++的項(xiàng)目或庫,可以通過把Xcode9中的libstdc++相關(guān)庫文件復(fù)制到Xcode10中即可。

在Xcode9中搜索libstdc++相關(guān)的庫,可以找到四個(gè)相關(guān)的文件:

/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個(gè)路徑中會(huì)就會(huì)發(fā)現(xiàn)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

所以我嘗試將libstdc++.6.0.9.dylib和libstdc++.6.0.9.tbd復(fù)制到Xcode10中,并制作libstdc++.6.dylib、libstdc++.dylib、libstdc++.6.tbd、libstdc++.tbd這四個(gè)替身文件,但是在模擬器上運(yùn)行崩潰,自己制作替身的方案不可行,然后我改為了制作副本的方式成功在模擬器上運(yùn)行。

libstdc++.6.0.9.dylib和libstdc++.6.0.9.tbd以及制作好的副本libstdc++.6.dylib、libstdc++.dylib、libstdc++.6.tbd、libstdc++.tbd下載地址點(diǎn)這里

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

推薦閱讀更多精彩內(nèi)容