简体   繁体   English

带有XCode的静态库c ++

[英]static library c++ with XCode

I'm trying to create a library of a group of files .cpp and .hpp in xcode. 我正在尝试在xcode中创建一组文件.cpp和.hpp的库。

All files run right in the simulator and in the device without library. 所有文件均可在模拟器和不带库的设备中直接运行。

And I have created the library and I have run it in the simulator (architecture x86) and run quite well. 我已经创建了该库,并且已经在模拟器(架构x86)中运行了该库,并且运行得很好。

When I tried to run the app with the library in the device I get an error like I would have forgotten any files: 当我尝试使用设备中的库运行应用程序时,出现错误,就像我忘记了任何文件一样:

Undefined symbols for architecture armv7:
"ssm::partialSortGreater(int, std::__1::vector<float, std::__1::allocator<float> > const&, std::__1::vector<int, std::__1::allocator<int> >&)", referenced from:

but It's running in the simulator with the same files, it's mental :S 但是它在模拟器中以相同的文件运行,这很重要:S

thanks :) 谢谢 :)

Update: 更新:

BuildSettings: Library and App BuildSettings:库和应用程序 图书馆

在此处输入图片说明

Update 2: 更新2:

Moreover if I Archive the app and I install it with iTunnes, works!!! 此外,如果我将应用程序存档并与iTunnes一起安装,则可以正常工作!!! in the device :S Very weird 在设备上:S很奇怪

A few things to check in this instance: 在这种情况下需要检查的几件事:

Make sure the library is not set to "Build active architecture only" and make sure that it has ARMv7 set as a valid architecture. 确保该库未设置为“仅构建活动架构”,并确保已将ARMv7设置为有效架构。

Also, make sure that the main project has your library listed in the Build phases under Target Dependancies and Link Binary with Libraries. 另外,请确保主项目的库在“构建阶段”下的“目标相关性”和“与库链接二进制文件”下列出。

If your library is not building the proper architecture or if your main project is not dependent on it's changes and not currently being linked against the static library your main project will not know that the static library exists. 如果您的库未构建正确的体系结构,或者您的主项目不依赖于其更改并且当前未与静态库链接,则您的主项目将不知道该静态库存在。

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

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