collect2: ld returned 1 exit status make: *** [ipvsadm] Error 1

邹晟睿
2023-12-01
在安装配置LVS时需要先进行安装ipvsadm,安装时报错如下

[root@lvsslave ipvsadm]# cd ipvsadm-1.26
[root@lvsslave ipvsadm-1.26]# make
make -C libipvs
make[1]: Entering directory `/root/ipvsadm/ipvsadm-1.26/libipvs'
gcc -Wall -Wunused -Wstrict-prototypes -g -fPIC -DLIBIPVS_USE_NL  -DHAVE_NET_IP_VS_H -c -o libipvs.o libipvs.c
gcc -Wall -Wunused -Wstrict-prototypes -g -fPIC -DLIBIPVS_USE_NL  -DHAVE_NET_IP_VS_H -c -o ip_vs_nl_policy.o ip_vs_nl_policy.c
ar rv libipvs.a libipvs.o ip_vs_nl_policy.o
ar: creating libipvs.a
a - libipvs.o
a - ip_vs_nl_policy.o
gcc -shared -Wl,-soname,libipvs.so -o libipvs.so libipvs.o ip_vs_nl_policy.o
make[1]: Leaving directory `/root/ipvsadm/ipvsadm-1.26/libipvs'
gcc -Wall -Wunused -Wstrict-prototypes -g  -DVERSION=\"1.26\" -DSCHEDULERS=\""rr|wrr|lc|wlc|lblc|lblcr|dh|sh|sed|nq"\" -DPE_LIST=\""sip"\"  -DHAVE_NET_IP_VS_H -c -o ipvsadm.o ipvsadm.c
ipvsadm.c: In function ‘print_largenum’:
ipvsadm.c:1383: warning: field width should have type ‘int’, but argument 2 has type ‘size_t’
gcc -Wall -Wunused -Wstrict-prototypes -g  -DVERSION=\"1.26\" -DSCHEDULERS=\""rr|wrr|lc|wlc|lblc|lblcr|dh|sh|sed|nq"\" -DPE_LIST=\""sip"\"  -DHAVE_NET_IP_VS_H -c -o config_stream.o config_stream.c
gcc -Wall -Wunused -Wstrict-prototypes -g  -DVERSION=\"1.26\" -DSCHEDULERS=\""rr|wrr|lc|wlc|lblc|lblcr|dh|sh|sed|nq"\" -DPE_LIST=\""sip"\"  -DHAVE_NET_IP_VS_H -c -o dynamic_array.o dynamic_array.c
gcc -Wall -Wunused -Wstrict-prototypes -g -o ipvsadm ipvsadm.o config_stream.o dynamic_array.o libipvs/libipvs.a  -lnl
ipvsadm.o: In function `parse_options'
:############下方为具体报错信息
/root/ipvsadm/ipvsadm-1.26/ipvsadm.c:432: undefined reference to `poptGetContext'
/root/ipvsadm/ipvsadm-1.26/ipvsadm.c:435: undefined reference to `poptGetNextOpt'
/root/ipvsadm/ipvsadm-1.26/ipvsadm.c:660: undefined reference to `poptBadOption'
/root/ipvsadm/ipvsadm-1.26/ipvsadm.c:502: undefined reference to `poptGetNextOpt'
/root/ipvsadm/ipvsadm-1.26/ipvsadm.c:667: undefined reference to `poptStrerror'
/root/ipvsadm/ipvsadm-1.26/ipvsadm.c:667: undefined reference to `poptBadOption'
/root/ipvsadm/ipvsadm-1.26/ipvsadm.c:670: undefined reference to `poptFreeContext'
/root/ipvsadm/ipvsadm-1.26/ipvsadm.c:677: undefined reference to `poptGetArg'
/root/ipvsadm/ipvsadm-1.26/ipvsadm.c:678: undefined reference to `poptGetArg'
/root/ipvsadm/ipvsadm-1.26/ipvsadm.c:679: undefined reference to `poptGetArg'
/root/ipvsadm/ipvsadm-1.26/ipvsadm.c:690: undefined reference to `poptGetArg'
/root/ipvsadm/ipvsadm-1.26/ipvsadm.c:693: undefined reference to `poptFreeContext'
collect2: ld returned 1 exit status
make: *** [ipvsadm] Error 1


以上错误百度有许多等同案例,初步判断是缺少依赖包导致make失败,首先检查两个包是否存在,其次要核对报错信息是否与缺少这两个包的报错类似,64bit的kernel-headers,popt-static的两个包

[root@lvsmaster ipvsadm-1.26]# rpm -qa | grep kernel-headers 
kernel-headers-2.6.32-573.el6.x86_64

[root@lvsmaster ipvsadm-1.26]# rpm -qa | grep popt-static

经过查询,本系统缺少popt-static包

去官网进行wget

[root@lvsmaster ~]# wget http://mirror.centos.org/centos/6/os/x86_64/Packages/popt-static-1.13-7.el6.x86_64.rpm
--2016-05-19 00:30:18--  http://mirror.centos.org/centos/6/os/x86_64/Packages/popt-static-1.13-7.el6.x86_64.rpm
Resolving mirror.centos.org... 103.27.60.52
Connecting to mirror.centos.org|103.27.60.52|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 21972 (21K) [application/x-rpm]
Saving to: “popt-static-1.13-7.el6.x86_64.rpm”

100%[=========================================================================================================================================================>] 21,972      29.2K/s   in 0.7s    

2016-05-19 00:30:19 (29.2 KB/s) - “popt-static-1.13-7.el6.x86_64.rpm” saved [21972/21972]

[root@lvsmaster ~]# rpm -ivh popt-static-1.13-7.el6.x86_64.rpm 
warning: popt-static-1.13-7.el6.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID c105b9de: NOKEY
Preparing...                ########################################### [100%]
   1:popt-static            ########################################### [100%]

安装完成后,再次进行make,这次没有ERROR返回,表明ipvsadm已经安装成功了
[root@lvsmaster ipvsadm-1.26]# make
make -C libipvs
make[1]: Entering directory `/root/ipsvadm/ipvsadm-1.26/libipvs'
gcc -Wall -Wunused -Wstrict-prototypes -g -fPIC -DLIBIPVS_USE_NL  -DHAVE_NET_IP_VS_H -c -o libipvs.o libipvs.c
gcc -Wall -Wunused -Wstrict-prototypes -g -fPIC -DLIBIPVS_USE_NL  -DHAVE_NET_IP_VS_H -c -o ip_vs_nl_policy.o ip_vs_nl_policy.c
ar rv libipvs.a libipvs.o ip_vs_nl_policy.o
ar: creating libipvs.a
a - libipvs.o
a - ip_vs_nl_policy.o
gcc -shared -Wl,-soname,libipvs.so -o libipvs.so libipvs.o ip_vs_nl_policy.o
make[1]: Leaving directory `/root/ipsvadm/ipvsadm-1.26/libipvs'
gcc -Wall -Wunused -Wstrict-prototypes -g  -DVERSION=\"1.26\" -DSCHEDULERS=\""rr|wrr|lc|wlc|lblc|lblcr|dh|sh|sed|nq"\" -DPE_LIST=\""sip"\" -DHAVE_POPT -DHAVE_NET_IP_VS_H -c -o ipvsadm.o ipvsadm.c
ipvsadm.c: In function ‘print_largenum’:
ipvsadm.c:1383: warning: field width should have type ‘int’, but argument 2 has type ‘size_t’
gcc -Wall -Wunused -Wstrict-prototypes -g  -DVERSION=\"1.26\" -DSCHEDULERS=\""rr|wrr|lc|wlc|lblc|lblcr|dh|sh|sed|nq"\" -DPE_LIST=\""sip"\" -DHAVE_POPT -DHAVE_NET_IP_VS_H -c -o config_stream.o config_stream.c
gcc -Wall -Wunused -Wstrict-prototypes -g  -DVERSION=\"1.26\" -DSCHEDULERS=\""rr|wrr|lc|wlc|lblc|lblcr|dh|sh|sed|nq"\" -DPE_LIST=\""sip"\" -DHAVE_POPT -DHAVE_NET_IP_VS_H -c -o dynamic_array.o dynamic_array.c
gcc -Wall -Wunused -Wstrict-prototypes -g -o ipvsadm ipvsadm.o config_stream.o dynamic_array.o libipvs/libipvs.a -lpopt -lnl

make完成后,继续进行make install

[root@lvsmaster ipvsadm-1.26]# make install
make -C libipvs
make[1]: Entering directory `/root/ipsvadm/ipvsadm-1.26/libipvs'
make[1]: Nothing to be done for `all'.
make[1]: Leaving directory `/root/ipsvadm/ipvsadm-1.26/libipvs'
if [ ! -d /sbin ]; then mkdir -p /sbin; fi
install -m 0755 ipvsadm /sbin
install -m 0755 ipvsadm-save /sbin
install -m 0755 ipvsadm-restore /sbin
[ -d /usr/man/man8 ] || mkdir -p /usr/man/man8
install -m 0644 ipvsadm.8 /usr/man/man8
install -m 0644 ipvsadm-save.8 /usr/man/man8
install -m 0644 ipvsadm-restore.8 /usr/man/man8
[ -d /etc/rc.d/init.d ] || mkdir -p /etc/rc.d/init.d
install -m 0755 ipvsadm.sh /etc/rc.d/init.d/ipvsadm


 类似资料:

相关阅读

相关文章

相关问答