I have been trying to link log4cxx into my ObjC/ObjC++/C++ project. It compiles but always fails at the link stage due to undefined symbols. By turning on the Xcode build option "Display Mangled Names" I was able to see why this is the case. The mangled names that the linker is looking for are different from the mangled names in the log4cxx.dylib file.
For example
"log4cxx::Logger::forcedLog(log4cxx::helpers::ObjectPtrT<log4cxx::Level> const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, log4cxx::spi::LocationInfo const&) const"
becomes
"__ZNK7log4cxx6Logger9forcedLogERKNS_7helpers10ObjectPtrTINS_5LevelEEERKNSt3__112basic_stringIcNS7_11char_traitsIcEENS7_9allocatorIcEEEERKNS_3spi12LocationInfoE"
from the linker's point of view. However the closest symbol that nm reports in log4cxx.dylib is
__ZNK7log4cxx6Logger9forcedLogERKNS_7helpers10ObjectPtrTINS_5LevelEEERKSbIwSt11char_traitsIwESaIwEERKNS_3spi12LocationInfoE
I created this library was created using the Xcode project provided by Apache.
I see that a similar question (How can I resolve single symbol link error when dynamically linking XCode project to lib4cxx library?) was asked earlier but there was no useful response.
A resolution would be greatly appreciated.
You have mismatched C++ standard library settings. Some of the code is using the new libc++, and some is using GNU's libstdc++. Choose the one you want and change the project settings so they're consistent.
You can use the c++filt command line tool to un-mangle C++ symbol names:
% c++filt __ZNK7log4cxx6Logger9forcedLogERKNS_7helpers10ObjectPtrTINS_5LevelEEERKNSt3__112basic_stringIcNS7_11char_traitsIcEENS7_9allocatorIcEEEERKNS_3spi12LocationInfoE
log4cxx::Logger::forcedLog(log4cxx::helpers::ObjectPtrT<log4cxx::Level> const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, log4cxx::spi::LocationInfo const&) const
% c++filt __ZNK7log4cxx6Logger9forcedLogERKNS_7helpers10ObjectPtrTINS_5LevelEEERKSbIwSt11char_traitsIwESaIwEERKNS_3spi12LocationInfoE
log4cxx::Logger::forcedLog(log4cxx::helpers::ObjectPtrT<log4cxx::Level> const&, std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> > const&, log4cxx::spi::LocationInfo const&) const
Note for example std::basic_string
(libstdc++) versus std::__1::basic_string
(libc++).