安装keepalived执行make报错的解决方法

在64位centos5.7下编译安装keepalived-1.2.2,执行make时出现错误。这个错误出现的原因可能是头文件 linux/types.h和sys/types.h的int64_t、u_int64_t定义有冲突,头文件linux/types.h在定义 int64_t等时没有防止重复定义,而sys/types.h头文件在定义int64_t等时是有防止重复定义的措施的。将sys/types.h(其 中包含了linux/types.h)放到所有头文件的前面包含,解决问题。

make[2]: Leaving directory `/root/keepalived-1.2.2/keepalived/vrrp'
make[2]: Entering directory `/root/keepalived-1.2.2/keepalived/libipvs-2.6'
gcc -g -O2 -DETHERTYPE_IPV6=0x86dd  -I/usr/src/linux/include -DLIBIPVS_DONTUSE_NL -Wall -Wunused -c -o libipvs.o libipvs.c
gcc -g -O2 -DETHERTYPE_IPV6=0x86dd  -I/usr/src/linux/include -DLIBIPVS_DONTUSE_NL -Wall -Wunused -c -o ip_vs_nl_policy.o ip_vs_nl_policy.c
In file included from /usr/include/netinet/in.h:23,
from ip_vs.h:12,
from ip_vs_nl_policy.c:1:
/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
make[2]: Leaving directory `/root/keepalived-1.2.2/keepalived/libipvs-2.6'
make[1]: *** [all] Error 1
make[1]: Leaving directory `/root/keepalived-1.2.2/keepalived'
make: *** [all] Error 2
解决办法:
# vim ./keepalived/libipvs-2.6/ip_vs.h
将#include <linux/types.h>移动到#include <sys/types.h>后面去。
再执行make编译顺利完成。

你可能感兴趣的:(keepalived)