关于iproute2-3.5.0交叉编译的问题

siasjack 2012-08-29 09:30:18
我在移植iproute2,下载的源码包在linux下可以直接make通过,但是我修改了Makefile的CC=mips-linux-gcc后编译不通过
环境是fedora12,内核是2.6.31.5
出现了下面的错误


ipnetns.c:5:25: sys/inotify.h: No such file or directory
ipnetns.c: In function `netns_exec':
ipnetns.c:151: warning: implicit declaration of function `unshare'
ipnetns.c:151: error: `CLONE_NEWNS' undeclared (first use in this function)
ipnetns.c:151: error: (Each undeclared identifier is reported only once
ipnetns.c:151: error: for each function it appears in.)
ipnetns.c: In function `netns_monitor':
ipnetns.c:253: warning: implicit declaration of function `inotify_init'
ipnetns.c:259: warning: implicit declaration of function `inotify_add_watch'
ipnetns.c:259: error: `IN_CREATE' undeclared (first use in this function)
ipnetns.c:259: error: `IN_DELETE' undeclared (first use in this function)
ipnetns.c:273: error: dereferencing pointer to incomplete type
ipnetns.c:273: error: dereferencing pointer to incomplete type
ipnetns.c:274: error: dereferencing pointer to incomplete type
ipnetns.c:275: error: dereferencing pointer to incomplete type
ipnetns.c:276: error: dereferencing pointer to incomplete type
ipnetns.c:277: error: dereferencing pointer to incomplete type
make[1]: *** [ipnetns.o] 错误 1
make[1]: Leaving directory `/home/jack/iproute2/iproute2-3.5.0/ip'
make: *** [all] 错误 2


请兄弟们帮忙
...全文
947 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
siasjack 2012-09-13
  • 打赏
  • 举报
回复
原因已经找到了,我有自己的编译工具,在编译工具里面也有自己的include,而在这个include里面却没有那个头文件,所以会出现没有头文件的错误,在程序里面修改头文件的位置或者吧系统的gcc头文件复制到编译工具的位置覆盖掉他自己的include就可以了!
siasjack 2012-08-29
  • 打赏
  • 举报
回复
然后我把源文件改了,第五行注释掉了,写成第六行
5 //#include <sys/inotify.h>
6 #include "/usr/include/sys/inotify.h"
然后定义了
31 # define CLONE_NEWNS 0x00020000
编译这个文件通过了
但是后来又出现了下面的错误

[root@ iproute2-3.5.0]# make
make[1]: Entering directory `/home/jack/iproute2/iproute2-3.5.0/lib'
make[1]: Nothing to be done for `all'.
make[1]: Leaving directory `/home/jack/iproute2/iproute2-3.5.0/lib'
make[1]: Entering directory `/home/jack/iproute2/iproute2-3.5.0/ip'
mipsel-linux-gcc -Wall -Wstrict-prototypes -O2 -I../include -DRESOLVE_HOSTNAMES -DLIBDIR=\"/usr/lib\" -DCONFDIR=\"/etc/iproute2\" -D_GNU_SOURCE -c -o ipnetns.o ipnetns.c
mipsel-linux-gcc -Wall -Wstrict-prototypes -O2 -I../include -DRESOLVE_HOSTNAMES -DLIBDIR=\"/usr/lib\" -DCONFDIR=\"/etc/iproute2\" -D_GNU_SOURCE -c -o rtm_map.o rtm_map.c
*
*省略
*
mipsel-linux-gcc -Wl,-export-dynamic ip.o ipaddress.o ipaddrlabel.o iproute.o iprule.o ipnetns.o rtm_map.o iptunnel.o ip6tunnel.o tunnel.o ipneigh.o ipntable.o iplink.o ipmaddr.o ipmonitor.o ipmroute.o ipprefix.o iptuntap.o ipxfrm.o xfrm_state.o xfrm_policy.o xfrm_monitor.o iplink_vlan.o link_veth.o link_gre.o iplink_can.o iplink_macvlan.o iplink_macvtap.o ipl2tp.o ../lib
/libnetlink.a ../lib/libutil.a -lresolv ../lib/libnetlink.a ../lib/libutil.a -ldl -o ip
ipnetns.o: In function `do_netns':ipnetns.c:(.text+0x480): undefined reference to `unshare'
:ipnetns.c:(.text+0x700): undefined reference to `inotify_init'
:ipnetns.c:(.text+0x720): undefined reference to `inotify_add_watch'
collect2: ld returned 1 exit status
make[1]: *** [ip] 错误 1
make[1]: Leaving directory `/home/jack/iproute2/iproute2-3.5.0/ip'
make: *** [all] 错误 2
[root@ iproute2-3.5.0]# vim ip/ipnetns.c

真的不知道到底怎么了!哪位大侠移植 过iproute2-3.5.0
求教啊
ForestDB 2012-08-29
  • 打赏
  • 举报
回复
toolchain不完全?
所谓交叉编译,不仅仅只是换个编译器吧。

69,373

社区成员

发帖
与我相关
我的任务
社区描述
C语言相关问题讨论
社区管理员
  • C语言
  • 花神庙码农
  • 架构师李肯
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧