• python build from source


    _bz2 build Failed

    在使用从源码构建的bzip2时,若出现如下错误

    building '_bz2' extension
    gcc -pthread -fPIC -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -std=c99 -Wextra -Wno-unused-result -Wno-unused-parameter -Wno-missing-field-initializers -Werror=implicit-function-declaration -I./Include/internal -I./Include -I. -I/usr/include/x86_64-linux-gnu -I/usr/local/include -I/home/cty-devops/packages/Python-3.8.7/Include -I/home/cty-devops/packages/Python-3.8.7 -c /home/cty-devops/packages/Python-3.8.7/Modules/_bz2module.c -o build/temp.linux-x86_64-3.8/home/cty-devops/packages/Python-3.8.7/Modules/_bz2module.o
    gcc -pthread -shared build/temp.linux-x86_64-3.8/home/cty-devops/packages/Python-3.8.7/Modules/_bz2module.o -L/usr/lib/x86_64-linux-gnu -L/usr/local/lib -lbz2 -o build/lib.linux-x86_64-3.8/_bz2.cpython-38-x86_64-linux-gnu.so
    /usr/bin/ld: /usr/local/lib/libbz2.a(bzlib.o): relocation R_X86_64_32S against `BZ2_crc32Table' can not be used when making a shared object; recompile with -fPIC
    /usr/local/lib/libbz2.a: error adding symbols: Bad value
    collect2: error: ld returned 1 exit status
    

     重新安装bzip2

    cd bzip2-1.0.6/
    
    # 替换makefile中的CC=gcc为CC=gcc -fPIC
    vim MakeFile
    vim Makefile-libbz2_so
    
    make && make install  

    参考https://stackoverflow.com/questions/63326781/usr-local-lib-libbz2-a-could-not-read-symbols-bad-value

    Openssl更新

    build时需要更新openssl

    Could not build the ssl module!
    Python requires an OpenSSL 1.0.2 or 1.1 compatible libssl with X509_VERIFY_PARAM_set1_host().
    LibreSSL 2.6.4 and earlier do not provide the necessary APIs, https://github.com/libressl-portable/portable/issues/381

    下载 openssl 源码 https://github.com/openssl/openssl/releases

    unzip openssl-OpenSSL_1_1_1i.zip
    cd openssl-OpenSSL_1_1_1i
    ./config shared
    make
    make install
    mkdir lib
    cp ./*.{so,so.1.1,a,pc} ./lib
    
    cd /your_python_source_code
    export LD_LIBRARY_PATH=/path/to/openssl-OpenSSL_1_1_1i/lib:$LD_LIBRARY_PATH
    
    LDFLAGS="-L/path/to/openssl-OpenSSL_1_1_1i/lib" ./configure (all your preferred options) --with-openssl=/path/to/openssl-OpenSSL_1_1_1i
    make
    make altinstall

      参考https://stackoverflow.com/questions/53543477/building-python-3-7-1-ssl-module-failed

    若出现

    File "/usr/local/lib/python3.8/ssl.py", line 98, in <module>
        import _ssl             # if we can't import it, let the error propagate
    ImportError: libssl.so.1.1: cannot open shared object file: No such file or directory
    

      在/etc/ld.so.conf中加入/path/to/openssl-OpenSSL_1_1_1i/lib

    echo "/path/to/openssl-OpenSSL_1_1_1i/lib" >> /etc/ld.so.conf
    ldconfig -v

    若出现uwsgi无法编译报ssl相关错误,尝试删除yum安装的openssl-devel  

     yum remove openssl-devel
    

      (参考https://blog.csdn.net/rongDang/article/details/102871874

  • 相关阅读:
    camp待补
    ZOJ
    ZOJ
    ZOJ
    CodeForces
    CodeForces
    POJ 3278 Catch That Cow(简单BFS)
    POJ 2251 Dungeon Master(三维BFS)
    POJ 1218 THE DRUNK JAILER(类开灯问题,完全平方数)
    HDU 2053 Switch Game(开灯问题,完全平方数)
  • 原文地址:https://www.cnblogs.com/QQQmadNULL/p/14340149.html
Copyright © 2020-2023  润新知