keepalived-1.2.2解包编译时有如下错误:
/usr/include/stdint.h:41: error: conflicting types for 'int64_t'
/usr/src/linux/include/linux/types.h:126: error: previous declaration of 'int64_t' was here
/usr/include/stdint.h:56: error: conflicting types for 'uint64_t'
/usr/src/linux/include/linux/types.h:124: error: previous declaration of 'uint64_t' was here
In file included from /usr/include/sys/uio.h:24,
from /usr/include/sys/socket.h:27,
from /usr/include/netinet/in.h:24,
from ip_vs.h:12,
from ip_vs_nl_policy.c:1:
/usr/include/sys/types.h:46: error: conflicting types for 'loff_t'
/usr/src/linux/include/linux/types.h:58: error: previous declaration of 'loff_t' was here
/usr/include/sys/types.h:62: error: conflicting types for 'dev_t'
/usr/src/linux/include/linux/types.h:22: error: previous declaration of 'dev_t' was here
In file included from /usr/include/sys/types.h:133,
from /usr/include/sys/uio.h:24,
from /usr/include/sys/socket.h:27,
from /usr/include/netinet/in.h:24,
from ip_vs.h:12,
from ip_vs_nl_policy.c:1:
/usr/include/time.h:105: error: conflicting types for 'timer_t'
/usr/src/linux/include/linux/types.h:31: error: previous declaration of 'timer_t' was here
In file included from /usr/include/sys/uio.h:24,
from /usr/include/sys/socket.h:27,
from /usr/include/netinet/in.h:24,
from ip_vs.h:12,
from ip_vs_nl_policy.c:1:
/usr/include/sys/types.h:204: error: conflicting types for 'u_int64_t'
/usr/src/linux/include/linux/types.h:125: error: previous declaration of 'u_int64_t' was here
In file included from /usr/include/sys/types.h:220,
from /usr/include/sys/uio.h:24,
from /usr/include/sys/socket.h:27,
from /usr/include/netinet/in.h:24,
from ip_vs.h:12,
from ip_vs_nl_policy.c:1:
/usr/include/sys/select.h:78: error: conflicting types for 'fd_set'
/usr/src/linux/include/linux/types.h:21: error: previous declaration of 'fd_set' was here
In file included from /usr/include/sys/uio.h:24,
from /usr/include/sys/socket.h:27,
from /usr/include/netinet/in.h:24,
from ip_vs.h:12,
from ip_vs_nl_policy.c:1:
/usr/include/sys/types.h:235: error: conflicting types for 'blkcnt_t'
/usr/src/linux/include/linux/types.h:142: error: previous declaration of 'blkcnt_t' was here
make[2]: *** [ip_vs_nl_policy.o] Error 1
可以采用如下办法解决:
vi keepalived-1.2.2/keepalived/libipvs-2.6/ip_vs.h
将以下行
#include <asm/types.h> /* For __uXX types */
#include <linux/types.h> /* For __beXX types in userland */
#include <netinet/in.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <arpa/inet.h>
替换为以下行
#include <asm/types.h> /* For __uXX types */
#include <sys/types.h>
#include <linux/types.h> /* For __beXX types in userland */
#include <netinet/in.h>
#include <sys/socket.h>
#include <arpa/inet.h>
也就是将#include <sys/types.h>放到#include <linux/types.h>的前面
问题原因:循环引用问题。