vsftpd移植到开发板上,交叉编译报 undefined reference to `__stack_chk_fail'和undefined reference to `__stack_错的解决办法

本文记录了解决vsftpd在arm-openwrt-linux-gcc交叉编译环境下出现的undefined reference to `__stack_chk_guard' 和 `__stack_chk_fail' 错误的过程。通过在Makefile中加入-fno-stack-protector选项并执行make clean后再make,成功解决了问题。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

原本在开发版上已经移植好了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.youkuaiyun.com/littlehedgehog/article/details/2242113   标题:编译出错 "undefined reference to"
http://bbs.youkuaiyun.com/topics/350133222 标题: gcc编译错误undefined reference to `__stack_chk_fail'







评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值