I am trying to describe my problem clearly for you, so it might be a little long, and I really appreciate that if you can read it and provide some suggestion. Thanks.
I have a library project, let's call it MyCppLib
, which contains some legacy c++ code, and I add a adapter class in this project so that I can use it with out using objective-c++ in other project. Here is an overview of MyCppLib
project.
Project MyCppLib
- some legacy c++ code
- Adapter.h
- Adapter.mm
I have another project, let's call it Main
project, which use the MyCppLib
project as a static library. So I use xCode 4 to compile MyCppLib
, and get libMyCppLib.a
, and config Main
project in xCode 4 to link it with Main
project. Here is an overview of Main
project.
Project Main
- Some objective-c classes which DO NOT contain '.mm' file
- Adapter.h
- libMyCppLib.a as a static library
While I compile the Main
project in xCode 4 I get some errors:
Undefined symbols for architecture armv6:
"operator new(unsigned long)", referenced from:
-[Adapter init] in libMyCppLib.a(Adapter.o)
my::cpp::namespace::MyCppClass::MyCppClass()in libMyCppLib.a(MyCppClass.o)... some other similar errors
ld: symbol(s) not found for architecture armv6
collect2: ld returned 1 exit status
I figure it might because the Main
project do not have an objective-c++ capability, so I add a '.mm' file to the Main
project. And now Main
project should be like this:
Project Main
- Some objective-c classes which DO NOT contain '.mm' file
- Adapter.h
- libMyCppLib.a as a static library
- DummyObjCpp.h
- DummyObjCpp.mm
Then, I compile the Main
project, and it succeed!
So, finally, my question is: how can I configure the Main
project to have objective-c++ capability without adding a '.mm' file?