I\'ve got a large static library in C++ with bits of Objective-C originally built for iOS (armv7).
I built a OS X (64-bit Intel x86_64) version of it, but as soon as
Change the standard library that is linked to use libstdc++
instead of libc++
- the problem is that the other library was compiled using the g++
mode which uses the libstdc++
library.
Consider the following sample code:
dhcp-191:~/Development/testy/fred% cat fred.cpp
#include
#include
#include "fred.h"
using namespace std;
bool dofred(string &x)
{
cout << x << endl;
return true;
}
dhcp-191:~/Development/testy/fred% cat fred.h
#include
#include
bool dofred(std::string &x);
dhcp-191:~/Development/testy/fred% clang++ -stdlib=libc++ -shared -o fred.dylib fred.cpp
dhcp-191:~/Development/testy/fred% nm fred.dylib | c++filt | grep dofred
0000000000000fa0 T dofred(std::__1::basic_string, std::__1::allocator >&)
dhcp-191:~/Development/testy/fred% clang++ -stdlib=libstdc++ -shared -o fred.dylib fred.cpp
dhcp-191:~/Development/testy/fred% nm fred.dylib | c++filt | grep dofred
0000000000000e30 T dofred(std::string&)
You get two completely different exported symbols. When trying to use the symbol, the app that uses the same -stdlib
flag will be able to link, while the app that doesn't will display a link error.