简体   繁体   English

将iOS部署目标更改为iOS 7.0时Xcode 5的C ++链接错误

[英]C++ link error with Xcode 5 when changing iOS Deployment Target to iOS 7.0

I've upgraded to Xcode 5, and am able to build my project fine using existing settings. 我已经升级到Xcode 5,并且能够使用现有设置很好地构建我的项目。

Updating the Base SDK to 7.0 doesn't cause any problems. 将基本SDK更新到7.0不会引起任何问题。

But, when I change the iOS Deployment Target to iOS 7.0, I start getting link errors for standard C++ symbols. 但是,当我将iOS部署目标更改为iOS 7.0时,我开始收到标准C ++符号的链接错误。 eg: 例如:

Undefined symbols for architecture armv7 std::string::empty() const", referenced from...

What I have tried: 我尝试过的

  • Explicitly linking standard C++ libraries 显式链接标准C ++库
  • Changing the "C++ Standard Library" setting in Xcode 5. Tried both libstdc++, libc++ and "Compiler Default" 更改Xcode 5中的“ C ++标准库”设置。尝试了libstdc ++,libc ++和“编译器默认值”

It just isn't finding the C++ symbols if the Deployment Target is set to iOS 7.0, and it does if it is set to iOS 6.1. 如果将“部署目标”设置为iOS 7.0,则找不到C ++符号;如果将其设置为iOS 6.1,则不会找到C ++符号。

It turns out that if XCode can't find any C++ files in the project, then it assumes that libstd++ is not required. 事实证明,如果XCode在项目中找不到任何C ++文件,那么它将假定不需要libstd ++。 So, you have to manually add a C++ file to the project (an empty .mm file would be enough). 因此,您必须手动将C ++文件添加到项目中(一个空的.mm文件就足够了)。

All the credits go to this answer in this Stackoverflow thread . 所有的功劳都归于这个Stackoverflow线程中的 答案

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

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