• 【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,遇到这种错误应该先明确配置文件是否正常,然后再去找解决办法。

  • 相关阅读:
    单片机C语言实例:4、数码管左右移显示
    [极致用户体验] 你的 Link Button 能让用户选择新页面打开吗?
    C++设计模式之Strategy策略模式
    内网渗透之内网信息收集(四)
    SpringBoot中使用JDBC
    ssm基于javaweb体育运动会竞赛成绩管理系统springboot
    pycharm安装jupyter,用德古拉主题,但是输入行全白了,看不清,怎么办?
    学习MySQL的第一天:MySQL概述(基础篇)
    【C++】详解priority_queue(优先级队列)与函数对象
    (DenseNet)Densely Connected Convolutional Networks--Gao Huang
  • 原文地址:https://blog.csdn.net/qq_24835087/article/details/127737923