I'm having some issues with building and running several libraries in an XCode project in Xcode 4.2. Basically I'm trying to create a library (lib 1), I have a second library (lib 2) and a third party library (lib 3).
I have lib 1 with a target dependency on lib 2 and lib 3. I then added a target dependency for the main project on lib 1. For the time being I'm not including lib 3.
So right now lib 2 uses categories. In order to not get the unrecognized selector error message I added -ObjC
to lib 1's Other Linker Flags and I also added that flag to the main projects Other Linker Flags.
When I add lib 3 which requires its own set of frameworks it complains about the -ObjC
flag. If I remove it everything compiles fine but then I get the unrecognized selector error message. How do I fix that?
This was one of the errors I was getting:
ld: duplicate symbol _dmhash in
/Users/Daniel/Library/Developer/Xcode/DerivedData/blah/lib.a(aes128hash.o) and
/Users/Daniel/Library/Developer/Xcode/DerivedData/blah/lib.a(aes128hash.o) for architecture armv7
This error only showed up while the lib 3 (third party) was being used. It disappeared when I removed all the frameworks required by lib 3 and lib3 itself. I then added all the frameworks one at a time compiling each time. If I did that and added lib 3 at the end it would compile successfully as long as I left out -ObjC
from the linker flags. This of course resulted in me getting unrecognized selector.
Keep in mind I do not have the source for lib 3.
Update Well I nuked the categories from the previous project. That managed to get the third party lib to compile. The problem however is that once I started making calls to that lib I'm now getting a bunch of errors.
I had to add the third party lib along with libsqlite3.0.dylib and libz.dylib to both my lib and the app to reduce it the number of errors. I was getting 55 errors instead of 32 if I only added those libs to my own library.
Some of the errors are Undefined symbols for architecture armv7: "__ZNSs6assignEPKcm", referenced from: -[ZGXid50 processSidc:pn:nc:otp:] in libSecurIDLib.a(OtpProcessor.o) __ZN7MtEbU23C2Ev in libSecurIDLib.a(SidcCodeGenerator.o) __ZN17AbstractStatement8parseRowEP12sqlite3_stmt in libSecurIDLib.a(abstractstatement.o) _ZN6cSPej57LUshm17ERKSt6vectorIhSaIhEEiiRSs in libSecurIDLib.a(SidcAlgo.o) "_Znwm", referenced from: __ZNSt6vectorIhSaIhEE20_M_allocate_and_copyIPhEES3_mT_S4_ in libSecurIDLib.a(SecurIDLib.o) __ZNSt6vectorIhSaIhEE14_M_fill_insertEN9__gnu_cxx17__normal_iteratorIPhS1_EEmRKh in libSecurIDLib.a(SecurIDLib.o) -[ZGXid50 processSidc:pn:nc:otp:] in libSecurIDLib.a(OtpProcessor.o) __ZNSt6vectorIhSaIhEE20_M_allocate_and_copyIPKcEEPhmT_S6_ in libSecurIDLib.a(OtpProcessor.o) -[iueMb3 init] in libSecurIDLib.a(TokenAdministration.o) -[iueMb3 saveTokenToDatabase:] in libSecurIDLib.a(TokenAdministration.o) __ZN5boost6detail12shared_countC2I10TokenStoreEEPT_ in libSecurIDLib.a(TokenAdministration.o) ... "__ZNSs12_M_leak_hardEv", referenced from: _ZN11TokenMapper11convertDateERKN3RSA7SecurID9RtpStringIhEE in libSecurIDLib.a(tokenmapper.o) "_ZNSsC1EPKcRKSaIcE", referenced from: -[iueMb3 init] in libSecurIDLib.a(TokenAdministration.o) -[iueMb3 deleteToken:] in libSecurIDLib.a(TokenAdministration.o) -[iueMb3 removeAllTokens] in libSecurIDLib.a(TokenAdministration.o) -[qvFih2 init] in libSecurIDLib.a(AppDataManager.o) -[qvFih2 isEulaAccepted] in libSecurIDLib.a(AppDataManager.o) -[qvFih2 initAppData] in libSecurIDLib.a(AppDataManager.o) -[qvFih2 setEulaAccepted:] in libSecurIDLib.a(AppDataManager.o) ... "__ZSt9terminatev", referenced from: _ZN3RSA6Crypto15RandomNumberGen11getInstanceEv in libSecurIDLib.a(TokenData.o) "_ZdlPv", referenced from: __ZNSt12_Vector_baseIhSaIhEED2Ev in libSecurIDLib.a(SecurIDLib.o) __ZNSt6vectorIhSaIhEE13_M_assign_auxIPhEEvT_S4_St20forward_iterator_tag in libSecurIDLib.a(SecurIDLib.o) __ZNSt6vectorIhSaIhEE14_M_fill_insertEN9__gnu_cxx17__normal_iteratorIPhS1_EEmRKh in libSecurIDLib.a(SecurIDLib.o) -[ZGXid50 processSidc:pn:nc:otp:] in libSecurIDLib.a(OtpProcessor.o) __ZNSt6vectorIhSaIhEE13_M_assign_auxIPKcEEvT_S5_St20forward_iterator_tag in libSecurIDLib.a(OtpProcessor.o) -[iueMb3 init] in libSecurIDLib.a(TokenAdministration.o) -[iueMb3 saveTokenToDatabase:] in libSecurIDLib.a(TokenAdministration.o)
Any ideas?
Update 2
Changed the compiler setting under build options from the default Apple LLVM compiler 3.1 to LLVM GCC 4.2 and got a different set of errors, though still getting 32 errors.
Undefined symbols for architecture armv7: "std::basic_string, std::allocator >::assign(char const*, unsigned long)", referenced from: -[ZGXid50 processSidc:pn:nc:otp:] in libSecurIDLib.a(OtpProcessor.o) MtEbU23::MtEbU23()in libSecurIDLib.a(SidcCodeGenerator.o) AbstractStatement::parseRow(sqlite3_stmt*) in libSecurIDLib.a(abstractstatement.o) cSPej5::LUshm17(std::vector > const&, int, int, std::basic_string, std::allocator >&)in libSecurIDLib.a(SidcAlgo.o) "operator new(unsigned long)", referenced from: unsigned char* std::vector >::_M_allocate_and_copy(unsigned long, unsigned char*, unsigned char*)in libSecurIDLib.a(SecurIDLib.o) std::vector >::_M_fill_insert(__gnu_cxx::__normal_iterator > >, unsigned long, unsigned char const&)in libSecurIDLib.a(SecurIDLib.o) -[ZGXid50 processSidc:pn:nc:otp:] in libSecurIDLib.a(OtpProcessor.o) unsigned char* std::vector >::_M_allocate_and_copy(unsigned long, char const*, char const*)in libSecurIDLib.a(OtpProcessor.o) -[iueMb3 init] in libSecurIDLib.a(TokenAdministration.o) -[iueMb3 saveTokenToDatabase:] in libSecurIDLib.a(TokenAdministration.o) boost::detail::shared_count::shared_count(TokenStore*)in libSecurIDLib.a(TokenAdministration.o) ... "std::basic_string, std::allocator >::_M_leak_hard()", referenced from: TokenMapper::convertDate(RSA::SecurID::RtpString const&)in libSecurIDLib.a(tokenmapper.o) "std::basic_string, std::allocator >::basic_string(char const*, std::allocator const&)", referenced from: -[iueMb3 init] in libSecurIDLib.a(TokenAdministration.o) -[iueMb3 deleteToken:] in libSecurIDLib.a(TokenAdministration.o) -[iueMb3 removeAllTokens] in libSecurIDLib.a(TokenAdministration.o) -[qvFih2 init] in libSecurIDLib.a(AppDataManager.o) -[qvFih2 isEulaAccepted] in libSecurIDLib.a(AppDataManager.o) -[qvFih2 initAppData] in libSecurIDLib.a(AppDataManager.o) -[qvFih2 setEulaAccepted:] in libSecurIDLib.a(AppDataManager.o) ... "std::terminate()", referenced from: RSA::Crypto::RandomNumberGen::getInstance() in libSecurIDLib.a(TokenData.o)