即使在安装了cpmh库之后也未定义对cmph函数的引用 [英] Undefined reference to cmph functions even after installing cpmh library
问题描述
我在ubuntu上使用gcc 4.4.3.我使用命令安装了cmph库工具0.9-1
I am using gcc 4.4.3 on ubuntu. I installed cmph library tools 0.9-1 using command
sudo apt-get install libcmph-tools
sudo apt-get install libcmph-tools
现在,当我尝试编译示例程序vector_adapter_ex1.c时,gcc能够在其包含文件中检测到cmph.h库,但显示出多个错误,例如
Now, when I tried to compile example program vector_adapter_ex1.c , gcc is able to detect cmph.h library in its include file but is showing multiple errors like
vector_adapter_ex1.c :(.text + 0x93):对cmph_io_vector_adapter'
vector_adapter_ex1.c:(.text+0xa3): undefined reference to
cmph_config_new的未定义引用
vector_adapter_ex1.c :(.text + 0xbb):对cmph_config_set_algo'
vector_adapter_ex1.c:(.text+0xcf): undefined reference to
cmph_config_set_mphf_fd'
vector_adapter_ex1.c:(.text+0x93): undefined reference to cmph_io_vector_adapter'
vector_adapter_ex1.c:(.text+0xa3): undefined reference to
cmph_config_new'
vector_adapter_ex1.c:(.text+0xbb): undefined reference to cmph_config_set_algo'
vector_adapter_ex1.c:(.text+0xcf): undefined reference to
cmph_config_set_mphf_fd'
尽管这些都是在cmph库的源代码中定义的.
even though, these are all defined in the source code of the cmph library.
任何人都可以说出可能发生的错误,或者建议使用另一种方法来构建最小的完美哈希函数.
Could anyone tell the error that might have occurred or suggest an alternate method to go about building minimal perfect hash functions.
推荐答案
编译时必须链接cmph库.
gcc <file name> -lcmph
将链接cmph库.另外,您可以使用-L选项指定在其中搜索库的目录.
You have to link the cmph library while compiling.
gcc <file name> -lcmph
will link the cmph library. Additionally you can specify the directory where to search the library for, using -L option.
这篇关于即使在安装了cpmh库之后也未定义对cmph函数的引用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!