0
我使用静态库,让我们假设cityhash,我已经构建并安装到/ usr/local/lib。我有一个使用cityhash,例如文件foo.cxx:GCC不链接静态库依赖关系(makefile)
// foo.cxx
u64 get_hash(const std::string &s) {
return CityHash64(s.data(), s.size());
}
我建立一个静态库从它:
gcc -c foo.cxx => foo.o
ar rcs libfoo.a foo.a => libfoo.a
我还有一个文件,bar.cxx,它采用foo.cxx和间接的CityHash功能。我编译它,并用两个libcityhash.a和libfoo.a类似下面的链接:
gcc -c bar.cxx => bar.o
gcc -L. -o bar bar.o -lcityhash -lfoo
但是,这并不工作,链接器抱怨说CityHash64是不确定的参考。哪里不对?当我不做静态库libfoo.a
一切工作正常。