iOS导入第三方静态库的一些设置

在开发iOS程序的过程中,通常在导入第三方的类库(.a/.o)文件会报出一系列的错误:

1

2

3

4

5

6

7

8

9

10

11

12

13Undefined symbolsforarchitecture 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::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”。

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容