netlink socket 을 이용하는 코드 컴파일.
netlink socket 을 이용하는 코드를 컴파일 하고 싶습니다만, 이게 잘 되지 않네요. 우분투 9.04 이며, 커널버전은 2.6.28-15-generic 입니다.
뭔가 문제가 있는거 같은데...아마도 gcc 컴파일 할 때 문제인거 같습니다. 컴파일시에 다음과 같은 에러가 납니다. ;;
~/work/stuff-code/netlink$ gcc -I/lib/modules/2.6.28-15-generic/build/include -o mon_routing_table mon_routing_table.c
In file included from /lib/modules/2.6.28-15-generic/build/include/linux/socket.h:23,
from /lib/modules/2.6.28-15-generic/build/include/linux/netlink.h:4,
from /lib/modules/2.6.28-15-generic/build/include/linux/rtnetlink.h:4,
from mon_routing_table.c:5:
/lib/modules/2.6.28-15-generic/build/include/linux/uio.h:45: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘iov_length’
/lib/modules/2.6.28-15-generic/build/include/linux/uio.h:55: error: expected declaration specifiers or ‘...’ before ‘size_t’
In file included from /usr/include/sys/uio.h:29,
from /usr/include/sys/socket.h:28,
from mon_routing_table.c:7:
/usr/include/bits/uio.h:45: error: redefinition of ‘struct iovec’
In file included from /usr/include/sys/socket.h:40,
from mon_routing_table.c:7:
/usr/include/bits/socket.h:163: error: redefinition of ‘struct sockaddr’
/usr/include/bits/socket.h:176: error: redefinition of ‘struct __kernel_sockaddr_storage’
/usr/include/bits/socket.h:186: error: expected identifier before numeric constant
/usr/include/bits/socket.h:234: error: redefinition of ‘struct msghdr’
/usr/include/bits/socket.h:252: error: redefinition of ‘struct cmsghdr’
/usr/include/bits/socket.h:281: error: conflicting types for ‘__cmsg_nxthdr’
/lib/modules/2.6.28-15-generic/build/include/linux/socket.h:131: error: previous definition of ‘__cmsg_nxthdr’ was here
/usr/include/bits/socket.h:310: error: expected identifier before numeric constant
/usr/include/bits/socket.h:389: error: redefinition of ‘struct linger’
그래서 혹시나 해서 -I 옵션을 제거 하고 컴파일 해도 비슷한 증상입니다.
~/work/stuff-code/netlink$ gcc -o mon_routing_table mon_routing_table.c
In file included from /usr/include/linux/socket.h:23,
from /usr/include/linux/netlink.h:4,
from /usr/include/linux/rtnetlink.h:4,
from mon_routing_table.c:5:
/usr/include/linux/uio.h:37: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘iov_length’
/usr/include/linux/uio.h:47: error: expected declaration specifiers or ‘...’ before ‘size_t’
In file included from /usr/include/sys/uio.h:29,
from /usr/include/sys/socket.h:28,
from mon_routing_table.c:7:
/usr/include/bits/uio.h:45: error: redefinition of ‘struct iovec’
In file included from /usr/include/sys/socket.h:40,
from mon_routing_table.c:7:
/usr/include/bits/socket.h:163: error: redefinition of ‘struct sockaddr’
/usr/include/bits/socket.h:176: error: redefinition of ‘struct __kernel_sockaddr_storage’
/usr/include/bits/socket.h:186: error: expected identifier before numeric constant
/usr/include/bits/socket.h:234: error: redefinition of ‘struct msghdr’
/usr/include/bits/socket.h:252: error: redefinition of ‘struct cmsghdr’
/usr/include/bits/socket.h:281: error: conflicting types for ‘__cmsg_nxthdr’
/usr/include/linux/socket.h:129: error: previous definition of ‘__cmsg_nxthdr’ was here
/usr/include/bits/socket.h:310: error: expected identifier before numeric constant
/usr/include/bits/socket.h:389: error: redefinition of ‘struct linger’
으흠. 문제네요. ㅠㅠ
이런...컴파일이 되네요.
으흠. 컴파일이 되네요. 단지, 헤더 파일의 인클루딩 순서를 변경 했습니다.
본래...것.
변경...한 것.
으흠. 왜 이런거죠? 대략, 감은 오는데...(사실, 예전에도 이런적이 있었습니다...) 정확히...왜 이런 문제가 생기는지요? 혹은 이런 문제를 미연에 방지 할 수 있는 뭔가가 있나요?
댓글 달기