2022年11月15日 星期二

lazarus freePascal install and cross compile, on Host 64bit linux ,and cross to build win32 program

 *** My host is  linux ubuntu 18.04 64bit, 
*** target is to build linux 64bit  , and cross build win32 program
* download and install 3 packages : fpc-src, fpc-laz and lazarus-project


fpc-src_3.2.2-210709_amd64.deb
fpc-laz_3.2.2-210709_amd64.deb
lazarus-project_2.2.4-0_amd64.deb


* install 
$ sudo dpkg -i fpc-src_3.2.2-210709_amd64.deb
$ sudo dpkg -i fpc-laz_3.2.2-210709_amd64.deb
sudo apt install ./lazarus-project_2.2.4-0_amd64.deb
* check if successful
$ apt-cache policy fpc-src fpc-laz lazarus-project
** not need if you want remove 
** $ apt remove fpc-src fpc-laz lazarus-project


* How to build win32 exe file from  linux 64bit host
[00.] copy /usr/share/fpcsrc/3.2.2 to your ~/fpcsrc/3.2.2
[01.] cd ~/fpcsrc/3.2.2
[02.] make clean all OS_TARGET=win32 CPU_TARGET=i386
[03.] sudo make crossinstall OS_TARGET=win32 CPU_TARGET=i386 INSTALL_PREFIX=/usr
[04.] sudo ln -sf /usr/lib/fpc/3.2.2/ppcross386 /usr/bin/ppcross386
[05.] launch lazarus ,open a hello project,
     project options -- compiler options -- config and target
Target OS(-T) Win32
Target Cpu(-P) i386
Target processor 386/486(-cp80386)
[06.] Run -- clean up and build 



*** below is for 64bit host , to gen linux 32bit code

---- gedit i386-linux-ld ---
#!/bin/bash
# name this file /usr/bin/i386-linux-ld
ld -A elf32-i386 $@
----^^ and save to disk

----make file i386-linux-as ---
#!/bin/bash
# name this file /usr/bin/i386-linux-as
as --32 $@
----^^

* copy above 2 bash file to /usr/bin/ , and let it as exe file
$ chmod +x i386-linux-as
$ chmod +x i386-linux-ld

01. cd ~/fpcsrc/3.2.2
02. make clean all OS_TARGET=linux CPU_TARGET=i386
03. sudo make crossinstall OS_TARGET=linux CPU_TARGET=i386 INSTALL_PREFIX=/usr

標籤: , , , ,

0 個意見:

張貼留言

訂閱 張貼留言 [Atom]

<< 首頁