IOS7 (only) stdlibc++ linking issue

后端 未结 4 1837
盖世英雄少女心
盖世英雄少女心 2020-11-28 07:40

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 p

相关标签:
4条回答
  • 2020-11-28 07:58

    Thanks for your help. I have found solution. I was using -lstdc++ flag in other linker flags but it is not enough now. I had to add "libstdc++.6.0.9.dylib in BuildPhases->Link Binary With Libraries. There was somewhere in the net info that xcode has problems with ios7 stdc++ lib selection and it should be selected manually.

    Regards, Marek

    0 讨论(0)
  • 2020-11-28 08:09

    Just an update on this answer:

    This step is very important!

    Ensure that C++ Standard Library is set to libstdc++ (GNU c++ standard library) in the Apple LLVM 5.0 Compiler Build Settings

    Background:

    I have an iOS app that abruptly stopped building for iOS 7 with standard library link errors. I had been testing the app successfully on the simulator and on an iPad mini, and archived it as well, but when I added an iPhone 5S for testing, I started getting link errors (possibly because of a new architecture in the mix?).

    Searching the link errors on Google, I found advice to explicitly add libstdc++.dylib to the linked libraries. This did not work.

    I experimented by adding libstdc++.6.dylib to the linked libraries instead; this eliminated the link errors, but the app crashed in the standard C++ library code very early.

    Removing the explicit additions of the library and changing the compiler setting in Build Settings, as noted above, corrected the link errors and runtime problem.

    Thanks to rimestad for the pointer!

    0 讨论(0)
  • 2020-11-28 08:16

    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.

    0 讨论(0)
  • 2020-11-28 08:22

    I had a similar problem, but @MarekM's answer only solve part of my problem, so I tried to add libstdc++.dylib and libstdc++.6.dylib, and that makes all the compiling error gone.

    0 讨论(0)
提交回复
热议问题