以linux ARM64环境为例,到官网下载与CPU适配的FPC执行文件、FPC源码和Lazarus源码(整合安装包已修复lazarus在linux代码编辑不能输入中文的Bug,整合安装包下载链接: https://pan.baidu.com/s/1LsHv5COD6up5PJCBL-DZBw?pwd=tpm6 提取码: tpm6 ),并解压到适当的目录:
lazarus源码:
/home/用户名/lazarus
fpc执行文件:
/home/用户名/lazarus/fpc-3.2.2.aarch64-linux
fpc源码:
/home/用户名/lazarus/fpcsrc
整合包的版本为:
Lazarus 2.2.0,FPC 3.2.2
一、安装FPC
cd fpc-3.2.2.aarch64-linux sudo ./install.sh
提示下列时,输入?后的内容
Install prefix (/usr or /usr/local)? 直接回车 Install textmode IDE(y/n)?y Install FCL(y/n)?y Install Packages(y/n)?y Install Documentation (y/n)?y Install Demo (y/n)?y
二、安装lazarus
如果是第一次安装lazarus,需安装以下软件:
sudo apt-get install gdb gcc libx11-dev libgdk-pixbuf2.0-dev libcairo2-dev lpango-1.0 libpangox-1.0-dev xorg-dev libgtk2.0-dev libgdk-pixbuf2.0-dev libpango1.0-dev
cd lazarus
make clean all
等安装完成就可以。
三、编译“交叉编译”程序
sudo -i export FPCVER="3.2.2" cd /home/用户名/lazarus/fpc-3.2.2/ make clean all OS_TARGET=win64 CPU_TARGET=x86_64
建符号连接
make crossinstall OS_TARGET=win64 CPU_TARGET=x86_64 INSTALL_PREFIX=/usr ln -sf /usr/lib/fpc/"$FPCVER"/ppcrossx64 /usr/bin/ppcrossx64
完成交叉编译环境后就可以在linux编译 win64 x86_64的应用程序
编译成功的程序:
附录:
1、最新lazarus源码:
https://sourceforge.net/projects/lazarus/files/Lazarus%20Zip%20_%20GZip/
2、FPC执行文件:
https://sourceforge.net/projects/freepascal/files/Linux/3.2.2/
3、fpc源码:
https://sourceforge.net/projects/freepascal/files/Source/3.2.2/