Reason and solution for error -“/usr/bin/ld: cannot find -levent ”?

一曲冷凌霜 提交于 2021-02-19 03:36:27

问题


While compiling my program which is using libevent library I am using gcc option -levent. But I am getting this error -

/usr/bin/ld: cannot find -levent

I do not have libevent on my system so I am statically linking to it while compiling using

gcc -o Hello -static -I libevent-1.4.12-stable/ hello.c -levent

How can i resolve this?

Thanks in advance!


回答1:


Where is the libevent.(a|so) file on your system?

If it isn't on your system's library path then you will have to add a -L option adding its location to the list of paths searched by the linker for libraries.

e.g.

gcc -L/folder/containing/event/lib -levent mysource.cc



回答2:


You need to have the libevent on your system or need to specify its path explicitly (if its a third-party library you got with the headers).

I suspect its not in your default /lib paths.



来源:https://stackoverflow.com/questions/1721283/reason-and-solution-for-error-usr-bin-ld-cannot-find-levent

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