可是在编译libnet的sample中的c文件显示错误,如下
[root@bogon sample]# gcc tftp.c
/tmp/ccoxChZD.o: In function `main':
tftp.c:(.text+0x89): undefined reference to `libnet_init'
tftp.c:(.text+0x11a): undefined reference to `libnet_name2addr4'
tftp.c:(.text+0x167): undefined reference to `libnet_name2addr4'
tftp.c:(.text+0x3a7): undefined reference to `libnet_build_udp'
tftp.c:(.text+0x3bb): undefined reference to `libnet_geterror'
tftp.c:(.text+0x448): undefined reference to `libnet_build_ipv4'
tftp.c:(.text+0x45c): undefined reference to `libnet_geterror'
tftp.c:(.text+0x483): undefined reference to `libnet_write'
tftp.c:(.text+0x497): undefined reference to `libnet_geterror'
tftp.c:(.text+0x4db): undefined reference to `libnet_destroy'
tftp.c:(.text+0x4fd): undefined reference to `libnet_destroy'
collect2: ld 返回 1
[root@bogon sample]#
于 2012-10-27 13:13:46发表:
你顶层Makefile文件中这行连接库的#LIBS += net/libnet.a被注释了吧,除掉前面的#就可以了。
静静飞舞 于 2010-04-19 14:28:21发表:
谢谢楼上的 我在gcc的时候加上了-lnet 但是还是不可以,还是会出现上面的错误。。。。。。。。。
hantu 于 2010-04-18 22:33:43发表:
看libnet软件包的说明,看看是否要在gcc后加-l参数以链接函数库,并确认的#include语句写正确了没有.