|
|
在IPV6下写了一个小程序,涉及到ICMPV6等内容,在头文件包含了下面一些:
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include <unistd.h>
#include <time.h>
#include <errno.h>
#include <string.h>
#include<sys/types.h>
#include<netinet/in.h>
#include<sys/socket.h>
#include <netdb.h>
#include<pthread.h>
#include<linux/in6.h>
#include<linux/ipv6.h>
#include<linux/icmpv6.h>
在编译时老出现这样错误:
/usr/include/linux/in6.h:31: redefinition of `struct in6_addr'
/usr/include/linux/in6.h:43: redefinition of `struct sockaddr_in6'
/usr/include/linux/in6.h:51: redefinition of `struct ipv6_mreq'
把#include<linux/in6.h>去掉,编译通过,可 icmp6_socket=socket(AF_INET6,SOCK_RAW,IPPROTO_ICMPV6);
if(icmp6_socket<0)
{
fprintf(stderr,"socket error\n");
printf("%s\n","socket error");
exit(1);
又提示socket error
socket error SOCKET没建立成功
我用的编译命令是gcc -Wall -o main3 main3.c -lpthread
到底是哪里错了 ?IPV6下头文件包含哪一些?编译命令还要带什库吗?我的系统没挂IPV6,是不是和这个有关系?
我是初学,请大家多多帮助! |
|