Question

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: enter image description here

Every time I try to allocate a the class DyOpenCV (DyOpenCv *opencv = [DyOpenCv alloc]), I get a lot of errors: Compilation 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)?

Cheers,

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top