Linux兵工厂

V1

2022/11/23阅读:11主题:草原绿

蓝牙地址,你知多少?

zynq平台移植python3.10.5

x86下安装python3.10.5

在交叉编译python3之前需要在ubuntu主机上安装对应的x86版本,因为交叉编译时需要用到python解释器。ubuntu16.04下安装python3.10.5:

安装ctypes模块需要的库文件libffi

tar zxvf libffi-3.4.2.tar.gz
cd libffi-3.4.2
./configure --disable-docs
make
make install

编译安装python3.10.5

tar xvf Python-3.10.5.tar
cd Python-3.10.5
export LD_LIBRARY_PATH=/usr/local/lib
export LD_RUN_PATH=/usr/local/lib
./configure --enable-optimizations LDFLAGS="-L/usr/local/lib" CPPFLAGS="-I /usr/local/include"
make
make install

2. 交叉编译python3.10.5

交叉编译ctypes模块需要的库文件libffi

tar zxvf libffi-3.4.2.tar.gz
./configure --prefix=/opt/Xilinx2018_zynq/zynq_Python/Modules/libffi --build=x86_64-linux-gnu --target=arm-linux-gnueabihf --host=arm-linux-gnueabihf CC=/opt/Xilinx/SDK/2018.3/gnu/aarch32/lin/gcc-arm-linux-gnueabi/bin/arm-linux-gnueabihf-gcc CXX=/opt/Xilinx/SDK/2018.3/gnu/aarch32/lin/gcc-arm-linux-gnueabi/bin/arm-linux-gnueabihf-g++ AR=/opt/Xilinx/SDK/2018.3/gnu/aarch32/lin/gcc-arm-linux-gnueabi/bin/arm-linux-gnueabihf-ar RANLIB=/opt/Xilinx/SDK/2018.3/gnu/aarch32/lin/gcc-arm-linux-gnueabi/bin/arm-linux-gnueabihf-ranlib --disable-docs
make
make install

交叉编译python3.10.5

tar xvf Python-3.10.5.tar
cd Python-3.10.5
export LD_LIBRARY_PATH=/opt/Xilinx2018_zynq/zynq_Python/Modules/libffi/lib
export LD_RUN_PATH=/opt/Xilinx2018_zynq/zynq_Python/Modules/libffi/lib
./configure --prefix=/opt/Xilinx2018_zynq/zynq_Python/zynq_Python3.10.5 --build=x86_64-linux-gnu --target=arm-linux-gnueabihf --host=arm-linux-gnueabihf CC=/opt/Xilinx/SDK/2018.3/gnu/aarch32/lin/gcc-arm-linux-gnueabi/bin/arm-linux-gnueabihf-gcc CXX=/opt/Xilinx/SDK/2018.3/gnu/aarch32/lin/gcc-arm-linux-gnueabi/bin/arm-linux-gnueabihf-g++ AR=/opt/Xilinx/SDK/2018.3/gnu/aarch32/lin/gcc-arm-linux-gnueabi/bin/arm-linux-gnueabihf-ar RANLIB=/opt/Xilinx/SDK/2018.3/gnu/aarch32/lin/gcc-arm-linux-gnueabi/bin/arm-linux-gnueabihf-ranlib ac_cv_file__dev_ptmx=yes ac_cv_file__dev_ptc=yes --disable-ipv6 --with-ensurepip=yes --enable-optimizations LDFLAGS="-L/opt/Xilinx2018_zynq/zynq_Python/Modules/libffi/lib" CPPFLAGS="-I/opt/Xilinx2018_zynq/zynq_Python/Modules/libffi/lib"
make 
make install

打包python文件到目标板

  • tar cvf zynq_Python3.10.5.tar zynq_Python3.10.5
  • cp libffi.so.8.1.0 至目标板/usr/lib/
  • cd /usr/lib && ln -s libffi.so.8.1.0 libffi.so && libffi.so.8;libffi库是ctypes模块所需要的
  • tar zynq_Python3.10.5.tar至相应的目录,在/usr/bin/目录下建立python3解释器的软连接:cd /usr/bin && ln -s /app/zynq_Python3.10.5/bin/python3.10 python3

至此,python3环境已移植到目标板,运行python3命令来验证

分类:

移动端开发

标签:

移动端开发

作者介绍

Linux兵工厂
V1

高级Linux软件工程