include <linux/ipv6.h> include <netinet/in.h>

发布时间 2024-01-11 14:14:32作者: papering

redefinition of `struct in6_addr' 的解决办法

 

# make
[ 0%] Built target GENHDR
[ 0%] Building C object lib/CMakeFiles/websockets.dir/plat/unix/unix-sockets.c.o
In file included from /root/mylib/libwebsockets/lib/plat/unix/unix-sockets.c:31:0:
/usr/include/linux/ipv6.h:19:8: error: redefinition of ‘struct in6_pktinfo’
struct in6_pktinfo {
^
In file included from /root/mylib/libwebsockets/lib/plat/unix/./private-lib-plat-unix.h:31:0,
from /root/mylib/libwebsockets/lib/core/./private-lib-core.h:138,
from /root/mylib/libwebsockets/lib/plat/unix/unix-sockets.c:28:
/usr/include/netinet/in.h:538:8: note: originally defined here
struct in6_pktinfo
^
In file included from /root/mylib/libwebsockets/lib/plat/unix/unix-sockets.c:31:0:
/usr/include/linux/ipv6.h:24:8: error: redefinition of ‘struct ip6_mtuinfo’
struct ip6_mtuinfo {
^
In file included from /root/mylib/libwebsockets/lib/plat/unix/./private-lib-plat-unix.h:31:0,
from /root/mylib/libwebsockets/lib/core/./private-lib-core.h:138,
from /root/mylib/libwebsockets/lib/plat/unix/unix-sockets.c:28:
/usr/include/netinet/in.h:545:8: note: originally defined here
struct ip6_mtuinfo
^
make[2]: *** [lib/CMakeFiles/websockets.dir/plat/unix/unix-sockets.c.o] Error 1
make[1]: *** [lib/CMakeFiles/websockets.dir/all] Error 2
make: *** [all] Error 2

 

 vim  /root/mylib/libwebsockets/lib/plat/unix/unix-sockets.c 

#include <linux/ipv6.h> 改为  nclude <netinet/in.h>


28 #if defined(LWS_HAVE_LINUX_IPV6_H)
29 #include <netinet/in.h>
30 #endif