免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 2569 | 回复: 4
打印 上一主题 下一主题

Linux下文件编译出错 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2006-01-18 11:48 |只看该作者 |倒序浏览
在linux下写了一个关于snmp的trap的程序,编译时出现如下错误:
trap.o(.text+0x54): In function `main':
: undefined reference to `snmp_sess_init'
trap.o(.text+0x86): In function `main':
: undefined reference to `netsnmp_ds_set_int'
trap.o(.text+0xc3): In function `main':
: undefined reference to `snmp_open'
trap.o(.text+0xe9): In function `main':
: undefined reference to `snmp_sess_perror'
trap.o(.text+0x103): In function `main':
: undefined reference to `snmp_pdu_create'
trap.o(.text+0x12a): In function `main':
: undefined reference to `snmp_add_var'
trap.o(.text+0x14c): In function `main':
: undefined reference to `snmp_add_var'
trap.o(.text+0x171): In function `main':
: undefined reference to `snmp_send'
trap.o(.text+0x182): In function `main':
: undefined reference to `snmp_close'
collect2: ld returned 1 exit status

我是不是编译时少了什么参数?

论坛徽章:
1
荣誉版主
日期:2011-11-23 16:44:17
2 [报告]
发表于 2006-01-18 11:53 |只看该作者
你没有连库吧.
snmp的库.

我刚才找了一下.
locate snmp |grep so
/usr/lib/libnetsnmp.so.5
/usr/lib/libsnmp.so.5.1.2
/usr/lib/libnetsnmpagent.so.5.1.2
/usr/lib/libnetsnmptrapd.so.5
/usr/lib/libnetsnmpmibs.so.5.1.2
/usr/lib/libnetsnmpmibs.so.5
/usr/lib/libsnmp.so.5
/usr/lib/libnetsnmptrapd.so.5.1.2
/usr/lib/libnetsnmp.so.5.1.2
/usr/lib/libnetsnmphelpers.so.5
/usr/lib/libnetsnmphelpers.so.5.1.2
/usr/lib/libnetsnmpagent.so.5


编译连接的时候 -lsnmp

论坛徽章:
0
3 [报告]
发表于 2006-01-18 14:12 |只看该作者
我已经把-lsnmp加上了,结果显示:
/usr/bin/ld: cannot find -lsnmp
collect2: ld returned 1 exit status

论坛徽章:
0
4 [报告]
发表于 2006-01-18 19:33 |只看该作者
我也有过这样的问题

论坛徽章:
0
5 [报告]
发表于 2006-01-19 10:50 |只看该作者
gcc -g -I/usr/local/include  -o trap trap.c -lnetsnmp -lcrypto

我用上面的编译的,现在可以了。
又多加了一个参数
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP