问题
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
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): 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'
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.
回答1:
This might sound lame, but have you linked with libcmph.la?
回答2:
You can do gcc $(pkg-config --libs cmph) vector_adapter_ex1.c
assuming the library is installed. This will link you correctly.
回答3:
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.
来源:https://stackoverflow.com/questions/9512905/undefined-reference-to-cmph-functions-even-after-installing-cpmh-library