I have a Cocoa application, that links functionality from a Cocoa static library, which in turn links functionality from a C++ static library.
Each project has the correct dependency set for each library it uses. Both of the libraries compile and link without error.
When the application tries to link, it does not appear to be including the C++ support needed for my C++ static library.
I have broken this down to its simplest form: The application project is called 'Application', the Cocoa library project 'LibraryM' and the C++ library is 'LibraryCPP'.
LibraryCPP implements class CPPClass, and exposes that functionality through a 'C' api 'getTwo' in CPPInterface.h/cpp
The link command issued by Xcode is:
Ld /Users/douglasn/LinkTester/Application/build/Debug/Application.app/Contents/MacOS/Application normal i386 cd /Users/douglasn/LinkTester/Application setenv MACOSX_DEPLOYMENT_TARGET 10.5 /Developer/usr/bin/gcc-4.0 -arch i386 -isysroot /Developer/SDKs/MacOSX10.5.sdk -L/Users/douglasn/LinkTester/Application/build/Debug -F/Users/douglasn/LinkTester/Application/build/Debug -filelist /Users/douglasn/LinkTester/Application/build/Application.build/Debug/Application.build/Objects-normal/i386/Application.LinkFileList -mmacosx-version-min=10.5 /Users/douglasn/LinkTester/LibraryM/build/Debug/libLibraryM.a -framework Cocoa -o /Users/douglasn/LinkTester/Application/build/Debug/Application.app/Contents/MacOS/Application
with the output:
Undefined symbols: "operator new(unsigned long)", referenced from: _getTwo in libLibraryM.a(CPPInterface.o) "___gxx_personality_v0", referenced from: ___gxx_personality_v0$non_lazy_ptr in libLibraryM.a(SimpleCocoaClass.o) ___gxx_personality_v0$non_lazy_ptr in libLibraryM.a(CPPInterface.o) "___cxa_begin_catch", referenced from: _getTwo in libLibraryM.a(CPPInterface.o) "vtable for __cxxabiv1::__class_type_info", referenced from: typeinfo for CPPClassin libLibraryM.a(CPPClass.o) "operator delete(void*)", referenced from: _getTwo in libLibraryM.a(CPPInterface.o) CPPClass::~CPPClass()in libLibraryM.a(CPPClass.o) CPPClass::~CPPClass()in libLibraryM.a(CPPClass.o) CPPClass::~CPPClass()in libLibraryM.a(CPPClass.o) "___cxa_end_catch", referenced from: _getTwo in libLibraryM.a(CPPInterface.o) ld: symbol(s) not found collect2: ld returned 1 exit status
I have discovered that I can solve this by either renaming one or more source files in the application from .m to .mm, or simply 'getting info' on a .m file and changing the type to sourcecode.cpp.objcpp. When I do this the ld command stops using /Developer/usr/bin/gcc-4.0, and instead invokes /Developer/usr/bin/g++-4.0.
The problem I face is that my deliverable is the ObjectiveC++ library, and my customers are going to be writing Cocoa applications. I would like my library to just work 'out of the box', and not have to explain to my customers why they need to change the type of, or rename, one of their .m files so that C++ support is included by the linker.
Is there any way to have the ObjectiveC++ library instruct Xcode to use a linker command that supports C++, whenever that library is linked into an application?
Thanks and regards,
Douglas
--
Douglas J. Norton
|