我正在尝试使用谷歌的 cityhash 散列函数。我无法将它链接到我的 c++ 代码。我已经安装了 cityHash,它在我的 /usr/local/lib 中生成了 libcityhash.la 等文件。
我正在设置 LD_LIB_LIBRARY=/usr/local/lib,但它似乎没有链接到这些文件。
代码:
#include <iostream>
#include <fstream>
#include <cstdlib>
int main()
{
std::ifstream file("dev/urandom");
char buff[4096];
file.read(buff, 4096);
const uint128 hashed = CityHash128(buff,4096);
file.close();
}
编译:
g++ -o city cityHash.cpp
错误:
/tmp/cctSoHTX.o:在函数 main:cityHash.cpp:(.text+0x73):未定义引用 `CityHash128(char const*, unsigned long)' collect2:错误:ld 返回 1 退出状态
我包括“city.h”并尝试按如下方式编译它:
g++ -I /usr/local/include/ -L/usr/local/lib -llibcityhash.a cityHash.cpp -o city
但我仍然得到 :undefined reference to `CityHash128(char const*, unsigned long)' –