I created a Objective-C++ project that runs some C++ (OpenCV) code. It runs fine and everything works well. But then I decided to add these routines as a subproject to my MAIN PROJECT, I get errors whenever I try to use the subproject classes.
The thing is, my SUBPROJECT uses .mm source files whereas my MAIN PROJECT uses only .m source files:
Every time I try to allocate a the class DyOpenCV (
DyOpenCv *opencv = [DyOpenCv alloc]), I get a lot of errors:
Is that a tip to merge Obj-C with Obj-Cpp projects? Is that a special interface to use, once I am trying to run .mm files from .m ones? Even if the .mm files are from a subproject? Is it necessary to add all libraries of my subproject to my project (I already did that)?
You need to link against the c++ standard library. This normally happens automatically if your compile sources phase contains any c++ files, but if the c++ is all contained within a static library then you need to explicitly ask for it to be linked to the final executable.
Check the subproject's build settings. Look for the C++ Standard Library build option. If it's set to libc++ (llvm standard library), then add
-lc++ to your application's additional linker flags. If it's set to libstdc++ (gnu library), then add
-lstdc++ to your application's additional linker flags.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!Donate Us With