1. 程式人生 > 其它 >linux 下編譯python

linux 下編譯python

1. 下載Python原始碼

到 https://www.python.org/ftp/python/ 上下載與電腦對應版本的Python

2. 編譯

執行下列命令編譯安裝
--prefix設定安裝的位置,便於管理

./configure --host=arm-linux --build=arm-linux-gnueabihf ac_cv_file__dev_ptmx=no ac_cv_file__dev_ptc=no --disable-ipv6 --prefix=/home/apps/python3

host與本機的arm庫路徑名稱一致

2.1. 編譯中遇到的錯誤

  1. 遇到錯誤configure: error: readelf for the host is required for cross builds

    看樣子是缺少readelf這個檔案
    在arm-gcc的bin目錄下發現一個arm-linux-gnueabihf-readelf,在此目錄執行
ln -s arm-linux-gnueabihf-readelf arm-linux-readelf

 

  1. 遇到錯誤Fatal: You must get working getaddrinfo() function. or you can specify "--disable-ipv6".
    因為用不到IPv6,所以在configure後面加上--disable-ipv6

  2. configure: error: set ac_cv_file__dev_ptmx to yes/no in your CONFIG_SITE file when cross compiling


    在configure後面加上ac_cv_file__dev_ptmx=no即可

  3. configure: error: set ac_cv_file__dev_ptc to yes/no in your CONFIG_SITE file when cross compiling
    同樣加上ac_cv_file__dev_ptc=no

  4. configure: error: cannot run C compiled programs. If you meant to cross compile, use '--host'.
    交叉編譯需要設定--host--build兩個引數



作者:uenigma
連結:https://www.jianshu.com/p/7346cc4e41ac
來源:簡書
著作權歸作者所有。商業轉載請聯絡作者獲得授權,非商業轉載請註明出處。