错误的原因和解决方案-"/usr/bin/ld:找不到-levent"? [英] Reason and solution for error -"/usr/bin/ld: cannot find -levent "?

查看:81
本文介绍了错误的原因和解决方案-"/usr/bin/ld:找不到-levent"?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在编译使用libevent库的程序时,我使用的是gcc选项-levent.但我收到此错误-

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

/usr/bin/ld:找不到-levent

/usr/bin/ld: cannot find -levent

我的系统上没有libevent,因此我在使用进行编译时会静态链接到它

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

我该如何解决?

提前谢谢!

推荐答案

系统上的 libevent.(a | so)文件在哪里?

如果它不在系统的库路径中,则必须添加 -L 选项,将其位置添加到链接程序为库搜索的路径列表中.

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.

例如

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

这篇关于错误的原因和解决方案-"/usr/bin/ld:找不到-levent"?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆