Undefined reference to cmph functions even after installing cpmh library

爷,独闯天下 提交于 2019-12-11 17:14:32

问题


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.


回答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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!