抱歉,您的浏览器无法访问本站
本页面需要浏览器支持(启用)JavaScript
了解详情 >

参考资料

环境

  • 交叉工具链,gcc-linaro-arm-linux-gnueabihf-4.9-2014.09_linux
  • 安装目录,/home/fulong/rootfs/usr/local/

编译依赖

  • 编译zlib
1
2
3
4
5
6
7
# 配置
# 因为我用的交叉编译器是arm-linux-gnueabihf
# 其中$(TOOLS_TOP_DIR)/bin/是其中安装目录
$ CHOST=arm-linux-gnueabihf ./configure --prefix=$(TOOLS_TOP_DIR)/bin/
# 开始编译
$ make
$ make install
  • 编译 openssl
1
2
3
4
5
6
7
# 配置
$ CROSS_COMPILE=arm-linux-gnueabihf- CC=gcc ./config no-async no-asm shared --prefix=$(TOOLS_TOP_DIR)/bin
# 修改Makefile文件
# 3.把所有的 -m64 flag删掉
# 编译
$ make
$ make install
  • 编译 libffi
1
2
3
# 配置
$ ./configure --host=arm-linux-gnueabihf --prefix=$(TOOLS_TOP_DIR)/bin/
$ make && make install

编译x86版本

因为交叉编译的时候需要用到Python工具(如果有旧版本,如果不存在兼容问题,可以忽略这一步)

1
2
3
4
5
6
7
8
$ ./configure --prefix=$(TOOLS_TOP_DIR)/bin/
$ make
$ make install
# 把Python环境切换成现在的Python版本
$ export PATH=$PATH:$(TOOLS_TOP_DIR)/bin/bin
# 查看环境
$ python3 -V
# 如果是3.9版本的话就是切换成功

编译arm版本

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
$ make distclean
$ ./configure CC=arm-linux-gnueabihf-gcc CXX=arm-linux-gnueabihf-g++ \
--host=arm-linux-gnueabihf --build=x86_64-linux-gnu --target=arm-linux-gnueabihf --disable-ipv6 \
ac_cv_file__dev_ptmx=yes ac_cv_file__dev_ptc=yes --prefix=$(TOOLS_TOP_DIR)/bin/ \
--with-openssl=$(TOOLS_TOP_DIR)/bin/ --enable-shared \
LDFLAGS="-L$(TOOLS_TOP_DIR)/bin/lib -I$(TOOLS_TOP_DIR)/bin/include -lffi -lz" \
CFLAGS="-L$(TOOLS_TOP_DIR)/bin/lib -I$(TOOLS_TOP_DIR)/bin/include" \
CPPFLAGS="-L$(TOOLS_TOP_DIR)/bin/lib -I$(TOOLS_TOP_DIR)/bin/include" \
CFLAGS="-L$(TOOLS_TOP_DIR)/bin/lib -I$(TOOLS_TOP_DIR)/bin/include"
$ make -j16
# 编译完后提示
# Python build finished successfully!
# The necessary bits to build these optional modules were not found:
# _bz2 _curses _curses_panel
# _dbm _gdbm _lzma
# _sqlite3 _tkinter _uuid
# readline
# To find the necessary bits, look in setup.py in detect_modules() for the module's name.
#
#
# The following modules found by detect_modules() in setup.py, have been
# built by the Makefile instead, as configured by the Setup files:
# _abc atexit pwd
# time
# 基本的模块都已经安装完毕
make install

验证移植

1
2
3
python3
>>> print("hello world")
hello world

评论