I have a very small program in Xcode only displaying a label and changing the text of the label in the viewWillAppear method. The label.text should come from a C++ library with a function like this:
int getNumber(){
return 42;
}
The problem is, that including the class with #import “TestLibMain.h” in my *.mm(!) class and using the function with
TestLibMain *tlb = new TestLibMain();
int myInt = tlb->getNumber();
NSString *myString = [NSString stringWithFormat:@"%d",myInt];
doesn’t invoke a compiler error, but a linker error:
Undefined symbols for architecture i386:
“TestLibMain::getNumber()”, referenced from:
-[tbViewController buttonPressed:] in tbViewController.o
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
My impression is, that the cpp-class has not been compiled.
I tried a lot of things around, but somewhere it’s hanging. It’s all in the same directory, I use the .mm extension, everything fine, but always this linker error. Getting crazy 🙂
Mac OS X Lion, XCode 4.2
Any ideas?
in a
.cppor.mmdefinesgetNumber()as a free function. This:defines
getNumber()as a member ofTestLibMain.