【openwrt】【编译问题】openwrt编译问题

undefined reference to `pthread_once’

在某次openwrt编译过程中出现了undefined reference to pthread_once错误,具体报错信息如下:

openwrt/staging_dir/host/lib/libcrypto.a(libcrypto_la-eng_all.o): In function `ENGINE_load_builtin_engines':
eng_all.c:(.text+0x30): undefined reference to `pthread_once'
openwrt/staging_dir/host/lib/libcrypto.a(libcrypto_la-err.o): In function `ERR_load_ERR_strings':
err.c:(.text+0xb4e): undefined reference to `pthread_once'
openwrt/staging_dir/host/lib/libcrypto.a(libcrypto_la-err_all.o): In function `ERR_load_crypto_strings':
err_all.c:(.text+0xaf): undefined reference to `pthread_once'
openwrt/staging_dir/host/lib/libcrypto.a(libcrypto_la-c_all.o): In function `OpenSSL_add_all_ciphers':
c_all.c:(.text+0x9df): undefined reference to `pthread_once'
openwrt/staging_dir/host/lib/libcrypto.a(libcrypto_la-c_all.o): In function `OpenSSL_add_all_digests':
c_all.c:(.text+0x9ff): undefined reference to `pthread_once'
openwrt/staging_dir/host/lib/libcrypto.a(libcrypto_la-crypto_init.o):crypto_init.c:(.text+0x51): more undefined references to `pthread_once' follow
collect2: error: ld returned 1 exit status
scripts/Makefile.host:107: recipe for target 'scripts/extract-cert' failed
make[6]: *** [scripts/extract-cert] Error 1

尝试执行make clean或者make distclean重新编译均没有效果。
然后分析log发现是编译这个文件——kernel/scripts/extract-cert.c时报错,原因是找不到pthread_once函数定义(此函数定义在pthread库中)。

于是百度+Google了一圈发现有两种解法:

方法一

安装pthread并将它链接到程序。具体安装的命令是:

 sudo apt-get install manpages-posix manpages-posix-dev

安装后pthread动态库所在的路径为/usr/lib/x86_64-linux-gnu

方法二

修改kernel/scripts/Makefile

HOSTLDLIBS_extract-cert = $(CRYPTO_LIBS)  改为
HOSTLDLIBS_extract-cert = -lcrypto -pthread

但是我遇到的并非上述两种情况,因为我发现——根据我当前的配置文件,我就不应该编译kernel/scripts/extract-cert.c这个文件,也就是我当前kernel/.config并不是我预期的,所以这个问题的原因就是kernel的配置文件出现了错乱,所以解决办法也很简单:

手动去kernel目录下删除.config等所有配置文件,然后重新编译即可。

cd kernel/
rm -rf .config*

实际上,openwrt很多编译错误都是编译配置信息错乱导致的,实际编译的根本不是你预期的target,遇到这种错误应该先明确配置文件是否正常,然后再去找解决办法。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

知否,知否

来一杯冰美式把

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值