Let me apologize in advance for posting what I thought seemed would be a straightforward problem to solve just by searching but somehow I just can't seem to find the answer to.
I'm compiling a BSD Static Library which is a project I created in XCode 3.0
It's just a test library and has two files:
//TestLib.h
int TestLib();
//TestLib.cpp
#include <iostream>
int TestLib() {
std::cout << "Test Lib\n";
return 0;
}
I compile this and as expected no errors and I get in the ./build/release libTestLib.a Up until this point I have done nothing to the static lib project settings, only added the two source files and compiled.
Now, I create a new project, C++ Command line too and I just call it TestApp
and I have the following in main.cpp:
#include <iostream> #include <TestLib.h>
int main (int argc, char * const argv[]) {
TestLib();
// insert code here... std::cout << "Hello, World!\n"; return 0;
}
For the project settings I set the include path to include TestLib.h
Now what I do is I add libTestLib.a to the project by just doing add Existing File and selecting it. I look at the target and under TestApp->Link Binary With Library I see my library libTestLib.a and I assume it will compile and link just fine.
Of course the problem is now that it just doesn't work: Undefined symbols: "TestLib()", referenced from: _main in main.o ld: symbol(s) not found collect2: ld returned 1 exit status "TestLib()", referenced from: _main in main.o ld: symbol(s) not found collect2: ld returned 1 exit status
Build failed (1 error)
I have even taken it to the command line by trying to combine main.cpp with the libTestLib.a using g++ and it will not link at the command line either so I thought something must be wrong with the way I compile the library. But according to the docs symbols export by default so I don't know what I am doing wrong.
I have to think it's something really small and simple I'm not doing :-/
Any help will be really appreciated, thanks in advance.
yoroshiku onegaishumasu,
Cory
|