近日在尝试通过自定义的Kernel编译OpenWrt时,出现了如下错误:
make[5]: Entering directory ‘<working-dir>/build_dir/target-aarch64_generic_musl/linux-layerscape_armv8_64b/linux-5.4.42′
HOSTCC scripts/extract-cert
<working-dir>/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’
<working-dir>/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’
<working-dir>/staging_dir/host/lib/libcrypto.a(libcrypto_la-err_all.o): In function ERR_load_crypto_strings’: err_all.c:(.text+0x9f): undefined reference to pthread_once’
<working-dir>/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’
<working-dir>/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’
<working-dir>/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
Makefile:1105: recipe for target ‘scripts’ failed
make[5]: *** [scripts] Error 2
一开始是认为是config文件出现问题。尝试重新配置,依旧出现这个问题。通过摸索与搜索,得出以下结果:
编辑<openwrt主目录>/build_dir/target-x86_64_musl/linux-x86_64/linux-<版本号>/scripts/Makefile
搜索关键词:HOSTLDLIBS_extract-cert
将原始行注释,并在下方添加如下代码:
[info]HOSTLDLIBS_extract-cert = -lcrypto -lpthread[/info]
重新执行编译即可。
Enjoy~
📮Comments