原本在开发版上已经移植好了vsftpd程序,不过后面因为一些原因更新了开发的sdk。之后再此编译vsftpd时就出现了编译不过的情况,交叉编译器是arm-openwrt-linux-gcc
编译出错的地方的文字提示如下:
arm-openwrt-linux-gcc -o vsftpd main.o utility.o prelogin.o ftpcmdio.o postlogin.o privsock.o tunables.o ftpdataio.o secbuf.o ls.o postprivparent.o logging.o str.o netstr.o sysstr.o strlist.o banner.o filestr.o parseconf.o secutil.o ascii.o oneprocess.o twoprocess.o privops.o standalone.o hash.o tcpwrap.o ipaddrparse.o access.o features.o readwrite.o opts.o ssl.o sslslave.o ptracesandbox.o ftppolicy.o sysutil.o sysdeputil.o seccompsandbox.o -Wl,-s -fPIE -pie -Wl,-z,relro -Wl,-z,now `./vsf_findlibs.sh`
postlogin.o: In function `process_post_login':
postlogin.c:(.text+0x2614): undefined reference to `__stack_chk_guard'
sysutil.o: In function `vsf_sysutil_accept_timeout':
sysutil.c:(.text+0x1fa4): undefined reference to `__stack_chk_fail'
sysutil.c:(.text+0x1fac): undefined reference to `__stack_chk_guard'
sysutil.o: In function `vsf_sysutil_getsockname':
sysutil.c:(.text+0x2280): undefined reference to `__stack_chk_fail'
sysutil.c:(.text+0x2288): undefined reference to `__stack_chk_guard'
sysutil.o: In function `vsf_sysutil_getpeername':
sysutil.c:(.text+0x2358): undefined reference to `__stack_chk_fail'
sysutil.c:(.text+0x2360): undefined reference to `__stack_chk_guard'
sysutil.o: In function `vsf_sysutil_tzset':
sysutil.c:(.text+0x2e54): undefined reference to `__stack_chk_fail'
sysutil.c:(.text+0x2e5c): undefined reference to `__stack_chk_guard'
sysutil.o: In function `vsf_sysutil_parse_time':
sysutil.c:(.text+0x31e4): undefined reference to `__stack_chk_fail'
sysutil.c:(.text+0x31ec): undefined reference to `__stack_chk_guard'
sysdeputil.o: In function `vsf_sysutil_send_fd':
sysdeputil.c:(.text+0xa60): undefined reference to `__stack_chk_fail'
sysdeputil.c:(.text+0xa68): undefined reference to `__stack_chk_guard'
sysdeputil.o: In function `vsf_sysutil_recv_fd':
sysdeputil.c:(.text+0xb60): undefined reference to `__stack_chk_fail'
sysdeputil.c:(.text+0xb68): undefined reference to `__stack_chk_guard'
collect2: error: ld returned 1 exit status
make[2]: *** [vsftpd] 错误 1
make[2]: Leaving directory `/home/lee/M2_4.0/apps/netmoon/vsftpd/vsftpd-3.0.2'
make[1]: *** [all] 错误 2
make[1]: Leaving directory `/home/lee/M2_4.0/apps/netmoon/vsftpd'
make: *** [apps/netmoon/vsftpd] 错误 2
make[1]: Entering directory `/home/lee/M2_4.0'
make[1]: Leaving directory `/home/lee/M2_4.0'
make: *** [apps/netmoon/vsftpd] 错误 1
报错的提示说 postlogin.c sysutil.c sysdeputil.c中有未定义的引用。我在这些文件中看了也并没有引用名为__stack_chk_guard,__stack_chk_guard的函数。应该不是代码的问题。然后在网上看了一些资料,说的是需要在编译时加上-fno-stack-protector选项。然后去Makefile中在CFLAGS中加上了-fno-stack-protector,之后make clean一下,再make就好了。 记住一定要make clean一下。
下面是所参考的文章连接:
http://blog.csdn.net/littlehedgehog/article/details/2242113 标题:编译出错 "undefined reference to"
http://bbs.csdn.net/topics/350133222 标题: gcc编译错误undefined reference to `__stack_chk_fail'