iOS開發引入第三方類庫的問題


 

在開發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”。

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM