Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Link iOS app against both libstdc++ and libc++

Use case: I want to use a 3rd party static library that uses libstdc++ (cannot be changed), so I have to link my app against libstdc++. Now if I want to use C++11 features in my own code, I'd have to select libc++ in Xcode and additionally link against libstdc++ to satisfy the static library.

My problem is that even though I selected libc++ in "Build settings" and added "-lstdc++" to "Other linker flags" (also tried via "Build phases > Link Binary With Libraries"), I'm getting linker errors for the latter, that is for libstdc++ functions/classes referenced by the 3rd party lib.

How can I configure the project to link against both C++ standard libraries? It should theoretically be possible since libc++ will be in its own inline namespace std::__1.

like image 794
AndiDog Avatar asked Mar 25 '13 12:03

AndiDog


1 Answers

I just ran into this , and my solution was that instead of adding -lstdc++ on the other flags, that you put /usr/lib/libstdc++.dylib.

My hunch is that when xcode/clang has -std=c++ set, the older .dylib needs to be explicitly loaded.

like image 89
SonicBison Avatar answered Sep 20 '22 21:09

SonicBison