无法将LIBEVENT链接为C.
发布时间:2020-12-16 03:36:41 所属栏目:百科 来源:网络整理
导读:为什么这不起作用,文件test.c: #include event.hint main(void){ event_init(); return 0;} 然后: gcc -o test.o -c test.c运行正常,但是 链接: g -o test -levent test.o生成 test.o: In function `main':test.c:(.text+0x5): undefined reference to `e
为什么这不起作用,文件test.c:
#include <event.h> int main(void) { event_init(); return 0; } 然后: 链接: test.o: In function `main': test.c:(.text+0x5): undefined reference to `event_init' collect2: ld returned 1 exit status 所以它不能作为C链接.怎么解决这个?我需要将它链接为C并编译为C. 解决方法
这个问题已被多次询问.在Linux上,您应该将库放在编译命令中的对象和源文件之后.所以试试吧
g++ -Wall -g -c mytest.cc g++ -Wall -g mytest.o -levent -o mytest 避免调用您的测试程序 作为一个新手,记得总是编译所有警告问-Wall和调试-g并学习使用gdb (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |