简体   繁体   English

如何将C ++静态库正确包含到iOS项目中

[英]How to correctly include C++ static library to iOS project

I have a project which contains C++ static library (mylib.a), header for it (mylib.h) and objc class which use functions of this library ( .h/ .m). 我有一个项目,其中包含C ++静态库(mylib.a),其标头(mylib.h)和objc类,它们使用该库的功能( .h / .m)。 I'm trying to copy this files to another project but every time I'm getting linking error. 我正在尝试将此文件复制到另一个项目,但是每次出现链接错误时。

Undefined symbols for architecture armv7
_ClassNameFromLibrary
referenced from:
      -[LibraryUserClass init] in LibraryUserClass.o
ld: symbol(s) not found for architecture armv7
clang: error: linker command failed with exit code 1 (use -v to see invocation)

This library works correctly in another project. 该库在另一个项目中可以正常工作。 I tried to copy all setting from working project and it doesn't help. 我试图从工作项目中复制所有设置,但无济于事。

Try to add libxml2.dylib and libz.dylib In Link Binary With Libraries. 尝试在带有库的链接二进制文件中添加libxml2.dyliblibz.dylib

If that does not work, please refer this question answer: Undefined symbols for architecture armv7 如果这不起作用,请参考以下问题的答案: 体系结构armv7的未定义符号

通过改变文件固定myclass.mmyclass.mm

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM