I write a C++ library and when linking against the library the symbols in it cannot be found. Here's what I've got:
a.cpp:
void zak()
{
}
test.cpp:
extern void zak();
int main(int argc, const char ** argv)
{
zak();
}
Makefile:
all:
g++ -c -o a.o a.cpp
ar r libzak.a a.o
g++ -L. -lzak test.cpp -o test
Here is what make says on my (Linux Mint 13) box:
g++ -c -o a.o a.cpp
ar r libzak.a a.o
g++ -L. -lzak test.cpp -o test
/tmp/ccC4cnLV.o: In function `main':
test.cpp:(.text+0x7): undefined reference to `zak()'
collect2: error: ld returned 1 exit status
make: *** [all] Error 1
I am sure I am missing something obvious, but what is it?