I have an iOS project with lots of Obj-C sources and a few .cpp files.
There is one C++ class CalibrationFileReader, which I created in Xcode 6, which has a .h and a .cpp file. I can use that class from my Objective-C code.
I have a second pair of C++ files (stereo_v3.hpp, stereo_v3.cpp) which do not include a class, but only static functions. Those I added to the project from outside. When I try to use one of the functions (computePoseDifference), it compiles fine but Xcode refuses to link, complaining
Undefined symbols for architecture arm64:
"computePoseDifference(cv::Mat const&, cv::Mat const&, cv::Mat&, cv::Mat&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >)", referenced from:
Things I tried:
- Creating the files in Xcode and pasting the original code in them
- Manually add the
.cppfile to Compile Sources in Build Phases for my target (see image).
Neither resolved the problem.
Well, turns out Xcode was not the culprit, but the
staticmodifier I prefixed the function's declaration with. So the question was premature. I should've known, but of course, the static linkage makes them invisible for other translation units.