Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
747 views
in Technique[技术] by (71.8m points)

xcode - IOS7 (only) stdlibc++ linking issue

I need help. I had a framwork which was using stdc++ like std:string. Now when i have created new app for IOS7 only there is problem with linking this framework because of problems with stdc++ lib:

Undefined symbols for architecture armv7 "std::basic_string, std::allocator >::_Rep::_S_empty_rep_storage", referenced from ...

I have find out something strange that when i change the Deplyment target to ios6 in this app all is working fine. With ios7 i see errors.

I already have flag set in other linker flags: -lstdc++

Any idea what ami doing wrong?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

To be honest, I don't like the above answer, as it uses the static lib and not the dynamic!

I have had the problem myself and found that the problem is that xcode is unable to find any C++ files in you project and thus assumes that the libstc++ is not needed!

Quite annoying when you are linking to a static lib that uses it!!

Solution :

  • Add a empty .mm file to you project!
  • Ensure that C++ Standard Library is set to libstdc++ (GNU c++ standard library) in the Build Settings

This worked for me and I did not have to add -lstdc++ to Other Linker Flags!

Hope that helps others with the same problem.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...