• 【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
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14

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

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

    方法一

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

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

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

    方法二

    修改kernel/scripts/Makefile

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

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

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

    cd kernel/
    rm -rf .config*
    
    • 1
    • 2

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

  • 相关阅读:
    使用 Rust 和 cURL 库下载程序
    Day.js 基本使用
    基于Cat混沌与高斯变异的改进灰狼优化算法-附代码
    信号(软中断)
    ETHERNET IP站转MODBUS RTU协议网
    很多Oracle中的SQL语句在EF中写不出来
    JVM:(八)运行时数据区之方法区
    进程和线程的区别&&run和start区别与联系
    JavaScript数组去重的五种方法 | indexOf | new Set() | reduce includes | Object.keys
    智慧校园管理在疫情防控中的作用有哪些?
  • 原文地址:https://blog.csdn.net/qq_24835087/article/details/127737923