標籤:style blog 使用 os io strong 檔案 for
在開發iOS程式的過程中,通常在匯入第三方的類庫(.a/.o)檔案會報出一系列的錯誤:
Undefined symbols for architecture i386: "std::string::c_str() const", referenced from: MP4Chunk::putTag(std::string) in libHKSUMEyeSDK.a(MP4Chunk.o) "std::string::empty() const", referenced from: MP4Chunk::putTag(std::string) in libHKSUMEyeSDK.a(MP4Chunk.o) "std::allocator<char>::allocator()", referenced from: MP4Chunk::writeFtypTag() in libHKSUMEyeSDK.a(MP4Chunk.o) MP4Chunk::writeFreeTag() in libHKSUMEyeSDK.a(MP4Chunk.o) MP4Chunk::writeMdatTag() in libHKSUMEyeSDK.a(MP4Chunk.o) MP4Chunk::writeMoovTag() in libHKSUMEyeSDK.a(MP4Chunk.o) MP4Chunk::writeMvhdTag() in libHKSUMEyeSDK.a(MP4Chunk.o) MP4Chunk::WriteIODS() in libHKSUMEyeSDK.a(MP4Chunk.o) MP4Chunk::writeTrakTag() in libHKSUMEyeSDK.a(MP4Chunk.o)
看似缺少了某個類庫檔案,但多次檢查之後發現,沒缺少啥引用的,甚至跟原來的Demo一個都不差,這是怎麼回事?
由於第三方類庫多數是用C++或者C編寫的,在引用過程中,還需要告訴編譯器可能會出現的語言種類,以便使用對應的解譯器進行解析。
OK,那麼我們只需要在XCode環境中檢查以下幾個配置項是否與下面一致即可:
TARGETS->Build Settings,搜尋
1.Other Linker Flags:-ObjC
2.C++ Language Dialect:Compiler Default
3.C++ Standard Library:Compiler Default
4.Compile Sources As:Objective-C++或者設定為According to File Type,然後將引用到C++類庫的檔案尾碼改為“.mm”。