I have a library libDinosaurs-ios.a
that was build from a combination of C++ and Objective-C code, build for iOS. I have another C++ project that links against this library and obviously tries to call its functions.
The Objective-C code lives in:
// Utils.mm
const char* findApplicationPath()
{
NSString* appDirectory = [[NSBundle mainBundle] resourcePath];
return [appDirectory UTF8String];
}
The C++ code that calls is lives in:
// Dinosaurs.cpp
FILE* Dinosaurs::openFile(char const* pInFileName)
{
char applePath[IOS_PATH_MAX];
strcpy(applePath, findApplicationPath());
strcat(applePath, "/");
strcat(applePath, pInFileName);
FILE* pFile = fopen(applePath, "rb")
return pFile;
}
The library compiles seemingly correctly into the aforementioned .a
file. The problem arrises when I link a new project against this library. All functions that were originally in the Objective-C code produce the following link error:
Undefined symbols for architecture armv7:
"findApplicationPath()", referenced from:
Dinosaurs::openFile(char const*) in libDinosaurs-ios.a(Dinosaurs.o)
ld: symbol(s) not found for architecture armv7
clang: error: linker command failed with exit code 1 (use -v to see invocation)
To make stuff more difficult, I do not have an Xcode project for the project I'm trying to build, only a CMake file. What is causing this error, and how do I fix it? I tried the linker flag -ObjC
but that didn't solve it:
set_target_properties(DinosaurZoo PROPERTIES LINK_FLAGS "-ObjC" )