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”。

原文地址:https://www.cnblogs.com/jaenson/p/3892384.html