Undefined reference to cmph functions even after i

2019-09-16 04:24发布

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 tocmph_config_new' vector_adapter_ex1.c:(.text+0xbb): undefined reference to cmph_config_set_algo' vector_adapter_ex1.c:(.text+0xcf): undefined reference tocmph_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.

3条回答
爷的心禁止访问
2楼-- · 2019-09-16 04:52

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.

查看更多
走好不送
3楼-- · 2019-09-16 04:59

You can do gcc $(pkg-config --libs cmph) vector_adapter_ex1.c assuming the library is installed. This will link you correctly.

查看更多
何必那么认真
4楼-- · 2019-09-16 05:10

This might sound lame, but have you linked with libcmph.la?

查看更多
登录 后发表回答