首页 > 代码库 > 编译ipvsadm-1.26 错误:collect2: ld returned 1 exit status

编译ipvsadm-1.26 错误:collect2: ld returned 1 exit status

编译: ipvsadm-1.26 编译错误问题

[root@SquidMaster241 ipvsadm-1.26]# make

make -C libipvs

make[1]: Entering directory `/root/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-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-1.26/ipvsadm.c:432: undefined reference to `poptGetContext‘

/root/ipvsadm-1.26/ipvsadm.c:435: undefined reference to `poptGetNextOpt‘

/root/ipvsadm-1.26/ipvsadm.c:660: undefined reference to `poptBadOption‘

/root/ipvsadm-1.26/ipvsadm.c:502: undefined reference to `poptGetNextOpt‘

/root/ipvsadm-1.26/ipvsadm.c:667: undefined reference to `poptStrerror‘

/root/ipvsadm-1.26/ipvsadm.c:667: undefined reference to `poptBadOption‘

/root/ipvsadm-1.26/ipvsadm.c:670: undefined reference to `poptFreeContext‘

/root/ipvsadm-1.26/ipvsadm.c:677: undefined reference to `poptGetArg‘

/root/ipvsadm-1.26/ipvsadm.c:678: undefined reference to `poptGetArg‘

/root/ipvsadm-1.26/ipvsadm.c:679: undefined reference to `poptGetArg‘

/root/ipvsadm-1.26/ipvsadm.c:690: undefined reference to `poptGetArg‘

/root/ipvsadm-1.26/ipvsadm.c:693: undefined reference to `poptFreeContext‘

collect2: ld returned 1 exit status

make: *** [ipvsadm] Error 1

解决办法:

    yum -y install kernel-headers   popt-static 

[root@SquidMaster241 ipvsadm-1.26]# make clean

rm -f ipvsadm ipvsadm.spec ipvsadm-1.26.tar.gz

rm -rf debian/tmp

find . -name ‘*.[ao]‘ -o -name "*~" -o -name "*.orig" 
    -o -name "*.rej" -o -name core | xargs rm -f

make -C libipvs clean

make[1]: Entering directory `/root/ipvsadm-1.26/libipvs‘

rm -f *.[ao] *~ *.orig *.rej core *.so

make[1]: Leaving directory `/root/ipvsadm-1.26/libipvs‘

[root@SquidMaster241 ipvsadm-1.26]# make

make -C libipvs

make[1]: Entering directory `/root/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-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

[root@SquidMaster241 ipvsadm-1.26]# 
[root@SquidMaster241 ipvsadm-1.26]#  make install

make -C libipvs

make[1]: Entering directory `/root/ipvsadm-1.26/libipvs‘

make[1]: Nothing to be done for `all‘.

make[1]: Leaving directory `/root/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

[root@SquidMaster241 ipvsadm-1.26]# ipvsadm

 

本文出自 “欢迎评论,欢迎点赞” 博客,请务必保留此出处http://swq499809608.blog.51cto.com/797714/1554594

编译ipvsadm-1.26 错误:collect2: ld returned 1 exit status