Hi all,
I have a problem linking with a .a C static library I have compiled as a separate target.
My library is called libtest.a and has only one function: int test() which returns 1 always. I have put libtest.a and test.h (its header file) in a mylibrary_directory
Then I create a new iphone view base project and added mylibrary_directory to the library search path, the header search path and the user headers search paths in xcode. Also I have added the -ltest flag in other linker flags option.
When I make calls to test() in myProjectViewController.m it WORKS
- (void)viewDidLoad {
[super viewDidLoad];
test();
}
So far so good. But the problem occurs when I create a new C++ class in my project making calls to test(). Then the linker complains that the symbol _test() is not found and the projetc does NOT build.
myClass.h:
#import "test.h"
class myClass
{
int testCall();
}
myClass.mm:
int myClass::testCall()
{
return test();
}
I get:
Undefined symbols:
"test()", referenced from:
myClass::testCall() in myClass-64D20670AC6C3193.o
ld: symbol(s) not found
collect2: ld returned 1 exit status
The Ld command output does show the correct -ltest and -Lcorrect_paths
My guess is that I am missing some flags either when I compile my library or in myProject. Any ideas or help?
Thanks
Baba.