I use a static library, let's assume cityhash, which I've build and installed to /usr/local/lib. I have a file foo.cxx which uses cityhash, for example:
// foo.cxx
u64 get_hash(const std::string &s) {
return CityHash64(s.data(), s.size());
}
I build a static library from it:
gcc -c foo.cxx => foo.o
ar rcs libfoo.a foo.a => libfoo.a
I have another file, bar.cxx, which uses foo.cxx and indirectly CityHash function. I compile it, and link with both libcityhash.a and libfoo.a like the following:
gcc -c bar.cxx => bar.o
gcc -L. -o bar bar.o -lcityhash -lfoo
But this doesn't work, linker complains that CityHash64 is undefined reference. What is wrong? When I do not make a static library libfoo.a
everything works fine.