Sign in Join
Wiki copytemporary

Cross compiling for Win32 under Linux/it: what changed

Revision 1 to 2. Removed lines have a minus sign; added lines have a plus sign.

OldNewLine
1+## Contents
2+
3+ * 1 Suggerimenti per la Cross-Compilazione - creazione di binari per Win32 in ambiente Linux
4+ * 2 Lazarus ed il Compilatore Free Pascal
5+ * 2.1 La Cross-compilazione - cosa bisogna sapere
6+ * 2.2 Percé da *nix a windows e non viceversa.
7+ * 2.3 Download del codice sorgente del FPC
8+ * 2.4 Scaricare le gnu binutils.
9+ * 2.5 Cross build binutils
10+ * 2.6 Cross build FPC
11+ * 2.7 Configure your fpc.cfg
12+ * 2.8 Compilazione multipiattaforma dell'LCL e dei componenti lazarus
13+ * 2.9 Cross compiling a project
14+ * 2.10 Hints for Cross compiling and Lazarus
15+ * 2.11 Cross compiling and Lazarus Packages
16+ * 3 For Unix (general)
17+ * 4 Per Linux sotto Win32
18+ * 5 FreeBSD to sparc
19+ * 6 Per Mac OS X
20+ * 7 Contributi Originali
21+
122## Suggerimenti per la Cross-Compilazione - creazione di binari per Win32 in ambiente Linux
223
3-Dalla versione 0.9.10 esiste un rpm 'fpc-crosswin32', che installa i *binutils* necessari (p.e. cross assembler, cross linker), i file .ppu di fpc cross-compilati per win32 e modifica il file /etc/fpc.cfg.
24+Dalla versione 0.9.10 esiste un rpm 'fpc-crosswin32', che installa i _binutils_ necessari (p.e. cross assembler, cross linker), i file .ppu di fpc cross-compilati per win32 e modifica il file /etc/fpc.cfg.
425
5-Tuttavia non include i file cross-compilati .ppu dell'LCL. É necessario che questi siano compilati dall'utente dopo l'installazione dell'fpc-crosswin32.
26+Tuttavia non include i file cross-compilati .ppu dell'LCL. É necessario che questi siano compilati dall'utente dopo l'installazione dell'fpc-crosswin32.
627
728## Lazarus ed il Compilatore Free Pascal
829
930### La Cross-compilazione - cosa bisogna sapere
1031
11-Questo è una breve introduzione per i novizi.
32+Questo è una breve introduzione per i novizi.
1233
13-La sezione seguente descrive come impostare il sistema per la cross-compilazione, in modo tale che lavori sotto linux e crei eseguibili per win32 (o freebsd o dawin, o ...). Perché usare la cross-compilazione: il FreePascal è un compilatore con l'obiettivo di convertire un programma sorgente in uno binario (in linguaggio macchina). Questi file binari contengono numerose informazioni, ad esempio la descrizione di come il sistema operativo deve avviare l'eseguibile. Nella maggior parte dei casi i file binari sono specifici per una determinata piattaforma e possono essere utilizzati solo sulla piattaforma per la quale sono stati scritti.
34+La sezione seguente descrive come impostare il sistema per la cross-compilazione, in modo tale che lavori sotto linux e crei eseguibili per win32 (o freebsd o dawin, o ...). Perché usare la cross-compilazione: il FreePascal è un compilatore con l'obiettivo di convertire un programma sorgente in uno binario (in linguaggio macchina). Questi file binari contengono numerose informazioni, ad esempio la descrizione di come il sistema operativo deve avviare l'eseguibile. Nella maggior parte dei casi i file binari sono specifici per una determinata piattaforma e possono essere utilizzati solo sulla piattaforma per la quale sono stati scritti.
1435
15-Di per sé il FreePascal non richiede un setup complesso. Esso è in grado di creare binari per molte piattaforme. Ed in pratica può già farlo. Tuttavia il compilatore è solo una parte. Bisogna anche tener conto dell'assembler ed del linker. E purtroppo questi strumenti non sono in grado di creare direttamente codice multipiattaforma. Ecco è necessario far riferimento a linker 'ld' e assembler 'as' specifici per ciascuna piattaforma di destinazione. Fortunatamente, per risolvere tali problemi, è possibile ricorrere alle *binutils*. Dopo aver creato gli strumenti "cross", tutte le unit pascal di fpc saranno cross-compilate. Ad esempio, ci sarà un file system.ppu per ciascuna piattaforma di destinazione. Quindi sarà necessario settare il file di config dell'fpc, così che la compilazione multipiattaforma avvenga tanto facilmente da dimenticarsi tutti i noiosi dettagli. La stessa cosà dovrà essere fatta per l'LCL - la *lazarus component library*. Infine sarà possibile compilare programmi per win32 su Linux. Successivamente i programmi realizzati si potranno testare con wine, con una macchina virtuale o copiandoli direttamente su una macchina reale windows.
36+Di per sé il FreePascal non richiede un setup complesso. Esso è in grado di creare binari per molte piattaforme. Ed in pratica può già farlo. Tuttavia il compilatore è solo una parte. Bisogna anche tener conto dell'assembler ed del linker. E purtroppo questi strumenti non sono in grado di creare direttamente codice multipiattaforma. Ecco è necessario far riferimento a linker 'ld' e assembler 'as' specifici per ciascuna piattaforma di destinazione. Fortunatamente, per risolvere tali problemi, è possibile ricorrere alle _binutils_. Dopo aver creato gli strumenti "cross", tutte le unit pascal di fpc saranno cross-compilate. Ad esempio, ci sarà un file system.ppu per ciascuna piattaforma di destinazione. Quindi sarà necessario settare il file di config dell'fpc, così che la compilazione multipiattaforma avvenga tanto facilmente da dimenticarsi tutti i noiosi dettagli. La stessa cosà dovrà essere fatta per l'LCL - la _lazarus component library_. Infine sarà possibile compilare programmi per win32 su Linux. Successivamente i programmi realizzati si potranno testare con wine, con una macchina virtuale o copiandoli direttamente su una macchina reale windows.
1637
1738### Percé da *nix a windows e non viceversa.
1839
19-La ragione principale di ciò è che generare binari unix su una piattaforma estranea (un'altra unix o anche un'altra distribuzione Linux) è più complicato. Il linking statico è complicato di suo, maggiormente quello *shared*.
40+La ragione principale di ciò è che generare binari unix su una piattaforma estranea (un'altra unix o anche un'altra distribuzione Linux) è più complicato. Il linking statico è complicato di suo, maggiormente quello _shared_.
2041
21-You would need the used libraries from the target platform's (gtk, glib,libc etc), and a lot of additional configuring for ld. (library paths, dynlinker path etc)
42+You would need the used libraries from the target platform's (gtk, glib,libc etc), and a lot of additional configuring for ld. (library paths, dynlinker path etc)
2243
23-This has been partially done (for the static case), but it is hard since it needs manual postediting of linker files and linker commandline, and a deep understanding about what makes Unix binaries tick.
44+This has been partially done (for the static case), but it is hard since it needs manual postediting of linker files and linker commandline, and a deep understanding about what makes Unix binaries tick.
2445
2546### Download del codice sorgente del FPC
2647
27-Per realizzare programmi multipiattaforma purtroppo i binari non sono sufficienti, è dunque necessario scaricare i sorgenti completi del fpc. Si veda www.freepascal.org. Per ottenere i sorgenti è possibile usare SVN o una [daily snapshot](http://www.hu.freepascal.org/lazarus/).
48+Per realizzare programmi multipiattaforma purtroppo i binari non sono sufficienti, è dunque necessario scaricare i sorgenti completi del fpc. Si veda www.freepascal.org. Per ottenere i sorgenti è possibile usare SVN o una [daily snapshot](<http://www.hu.freepascal.org/lazarus/>).
2849
29-Per gli esempi che seguono si suppone che i sorgenti siano stati scaricati nella cartella *~/sources/fpc*.
50+Per gli esempi che seguono si suppone che i sorgenti siano stati scaricati nella cartella _~/sources/fpc_.
3051
3152### Scaricare le gnu binutils.
3253
33-É possibile scaricare l'ultima versione delle binutils da [<http://ftp.gnu.org/gnu/binutils/>](http://ftp.gnu.org/gnu/binutils/)\
34-Supponiamo di scaricare le binutils-2.xx.tar.gz nella cartella *~/download/*.
54+É possibile scaricare l'ultima versione delle binutils da <http://ftp.gnu.org/gnu/binutils/>
55+Supponiamo di scaricare le binutils-2.xx.tar.gz nella cartella _~/download/_.
3556
3657### Cross build binutils
3758
38-Nel repository di fpcbuild c'é uno script per creare le binutils per tutte le piattaforme: install/cross/buildcrossbinutils Prima di procedere visitate [<http://svn.freepascal.org/svn/fpcbuild/branches/>](http://svn.freepascal.org/svn/fpcbuild/branches/) e individuate la versione di vostro interesse.
39-
40-Per scaricare la cartella install da fpcbuild:
41-
42-` []$ cd ~`\
43-` []$ svn co `[`http://svn.freepascal.org/svn/fpcbuild/branches/fixes_2_2/install`](http://svn.freepascal.org/svn/fpcbuild/branches/fixes_2_2/install)` install`\
44-
45-(nota: verrà creata una nuova cartella *install* nella vostra home - la cartella NON deve esistere!)
46-
47-Creare una copia dello script:
48-
49-` []$ cd ~/install/cross/`\
50-` []$ cp buildcrossbinutils buildcrossbinutils.sh`
51-
52-Modificare le variabili all'inizio dello script.
53-
54-La variabile BASE punta ad una directori di lavoro ed installazione. Essa dovrebbe essere vuota. Per esempio:
59+Nel repository di fpcbuild c'é uno script per creare le binutils per tutte le piattaforme: install/cross/buildcrossbinutils Prima di procedere visitate <http://svn.freepascal.org/svn/fpcbuild/branches/> e individuate la versione di vostro interesse.
5560
56-` BASE=~/cross_fpc`
61+Per scaricare la cartella install da fpcbuild:
62+```
63+[]$ cd ~
64+ []$ svn co <http://svn.freepascal.org/svn/fpcbuild/branches/fixes_2_2/install> install
65+```
5766
58-Ora il file binutils scaricato. se per esempio è stato scaricato in ~/download/binutils-2.18.tar.gz allora impostare le variabili come segue
67+(nota: verrà creata una nuova cartella _install_ nella vostra home - la cartella NON deve esistere!)
5968
60-` BINUTILSPATH=~/download/`\
61-` BINUTILSBASE=binutils`\
62-` BINUTILSVERSION=2.18`\
63-` BINUTILS_GZIP=yes`
69+Creare una copia dello script:
70+```
71+[]$ cd ~/install/cross/
72+ []$ cp buildcrossbinutils buildcrossbinutils.sh
73+```
6474
65-Lo script aggancerà questo automaticamente a ~/download/binutils-2.18.tar.gz. Le variabili restanti da modificare definizcono la piattaforma di destinazione desiderata. Per default verranno considerate tutti i sistemi operativi supportati, ma cò richiede molto tempo (anche alcune ore su macchine lente). Per compilazioni per Windows, è necessario solo
75+Modificare le variabili all'inizio dello script.
6676
67-` TARGETS_WIN="mingw32"`\
68-` `
77+La variabile BASE punta ad una directori di lavoro ed installazione. Essa dovrebbe essere vuota. Per esempio:
78+```
79+BASE=~/cross_fpc
80+```
6981
70-e possono essere commentate le altre righe:
82+Ora il file binutils scaricato. se per esempio è stato scaricato in ~/download/binutils-2.18.tar.gz allora impostare le variabili come segue
83+```
84+BINUTILSPATH=~/download/
85+ BINUTILSBASE=binutils
86+ BINUTILSVERSION=2.18
87+ BINUTILS_GZIP=yes
88+```
7189
72-` #BSD="freebsd netbsd openbsd"`\
73-` #TARGETS_WIN="cygwin mingw32 msdosdjgpp"`\
74-` #TARGETS_I386="${BSD} linux solaris darwin"`\
75-` #TARGETS_POWERPC="${BSD} linux darwin"`\
76-` #TARGETS_SPARC="${BSD} linux solaris"`\
77-` #TARGETS_M68k=`
90+Lo script aggancerà questo automaticamente a ~/download/binutils-2.18.tar.gz. Le variabili restanti da modificare definizcono la piattaforma di destinazione desiderata. Per default verranno considerate tutti i sistemi operativi supportati, ma cò richiede molto tempo (anche alcune ore su macchine lente). Per compilazioni per Windows, è necessario solo
91+```
92+TARGETS_WIN="mingw32"
93+```
7894
79-Quindi lanciare lo script:
95+e possono essere commentate le altre righe:
96+```
97+#BSD="freebsd netbsd openbsd"
98+ #TARGETS_WIN="cygwin mingw32 msdosdjgpp"
99+ #TARGETS_I386="${BSD} linux solaris darwin"
100+ #TARGETS_POWERPC="${BSD} linux darwin"
101+ #TARGETS_SPARC="${BSD} linux solaris"
102+ #TARGETS_M68k=
103+```
80104
81-` []$ sh buildcrossbinutils.sh`\
82-` `
105+
106+Quindi lanciare lo script:
107+```
108+[]$ sh buildcrossbinutils.sh
109+```
83110
84-Lo script crea una sottocartella 'logs' contenente una serie di file di log. nel caso in cui ci dovessero essere errori partire osservando il contenuto di questi log.
111+Lo script crea una sottocartella 'logs' contenente una serie di file di log. nel caso in cui ci dovessero essere errori partire osservando il contenuto di questi log.
85112
86113Si noti che per molte piattaforme (Linux,FreeBSD, win32) queste sono disponibili già in forma compilata. Si veda: <ftp://freepascal.stack.nl/pub/fpc/contrib/cross/>
87114
88115### Cross build FPC
89116
90-Nel repositorio scaricato è presente uno script per costruire l'fpc snapshot per tutte le piattaforme: install/cross/buildcrosssnapshot Creare una copia dello script:
91-
92-` []$ cd ~/install/cross/`\
93-` []$ cp buildcrosssnapshot buildcrosssnapshot.sh`
94-
95-Modificare le variabili all'inizio del nuovo script.
96-
97-Normalmente è sufficiente modificare almeno le seguenti: CROSSTOOLSROOT, FPCCVS, DESTDIR, TARGETS_OS e TARGETS_CPU. Ad esempio:
117+Nel repositorio scaricato è presente uno script per costruire l'fpc snapshot per tutte le piattaforme: install/cross/buildcrosssnapshot Creare una copia dello script:
118+```
119+[]$ cd ~/install/cross/
120+ []$ cp buildcrosssnapshot buildcrosssnapshot.sh
121+```
98122
99-` CROSSTOOLSROOT=~/cross_fpc/cross`\
100-` FPCCVS=~/sources/fpc`\
101-` TARGETS_OS="win32"`\
102-` TARGETS_CPU="i386"`\
103-` DESTDIR=~/cross_fpc/`\
104-` `
123+Modificare le variabili all'inizio del nuovo script.
105124
106-Lanciare lo script:
125+Normalmente è sufficiente modificare almeno le seguenti: CROSSTOOLSROOT, FPCCVS, DESTDIR, TARGETS_OS e TARGETS_CPU. Ad esempio:
126+```
127+CROSSTOOLSROOT=~/cross_fpc/cross
128+ FPCCVS=~/sources/fpc
129+ TARGETS_OS="win32"
130+ TARGETS_CPU="i386"
131+ DESTDIR=~/cross_fpc/
132+```
107133
108-` []$ sh buildcrosssnapshot.sh`
134+Lanciare lo script:
135+```
136+[]$ sh buildcrosssnapshot.sh
137+```
109138
110-Fatto ciò le unit compilate si troveranno in ~/cross_fpc/
139+Fatto ciò le unit compilate si troveranno in ~/cross_fpc/
111140
112141### Configure your fpc.cfg
113142
114-Aprire come root il file /etc/fpc.cfg o creare una copia di /etc/fpc.cfg in ~/fpc.cfg ed editare questo file. Cercare nel config le stringhe seguenti:
115-
116-Nota: Su versioni obsolete di \$version e \$target sono ustae al posto di \$fpcversion e \$fpctarget
117-
118-`-Fu/usr/lib/fpc/$fpcversion/units/$fpctarget`\
119-`-Fu/usr/lib/fpc/$fpcversion/units/$fpctarget/*`\
120-`-Fu/usr/lib/fpc/$fpcversion/units/$fpctarget/rtl`
143+Aprire come root il file /etc/fpc.cfg o creare una copia di /etc/fpc.cfg in ~/fpc.cfg ed editare questo file. Cercare nel config le stringhe seguenti:
121144
122-Rimpiazzarle con il seguente codice (l'esempio è riferito ad una piattaforma linux per compilazioni win32):
145+Nota: Su versioni obsolete di $version e $target sono ustae al posto di $fpcversion e $fpctarget
146+```
147+-Fu/usr/lib/fpc/$fpcversion/units/$fpctarget
148+ -Fu/usr/lib/fpc/$fpcversion/units/$fpctarget/*
149+ -Fu/usr/lib/fpc/$fpcversion/units/$fpctarget/rtl
150+```
123151
124-`#IFDEF win32`\
125-`-Fu~/cross_fpc/lib/fpc/$fpcversion/cross/units/i386-win32/`\
126-`-Fu~/cross_fpc/lib/fpc/$fpcversion/cross/units/i386-win32/*`\
127-`-Fu~/cross_fpc/lib/fpc/$fpcversion/cross/units/i386-win32/rtl`\
128-`-XPi686-mingw32-`\
129-`-FD~/cross_fpc/cross/bin`\
130-`#ELSE linux`\
131-`-Fu/usr/lib/fpc/$fpcversion/units/$fpctarget`\
132-`-Fu/usr/lib/fpc/$fpcversion/units/$fpctarget/*`\
133-`-Fu/usr/lib/fpc/$fpcversion/units/$fpctarget/rtl`\
134-`#-Fu~/fpc/packages/*;~/fpc/rtl/linux`\
135-`#ENDIF`
152+Rimpiazzarle con il seguente codice (l'esempio è riferito ad una piattaforma linux per compilazioni win32):
153+```
154+#IFDEF win32
155+ -Fu~/cross_fpc/lib/fpc/$fpcversion/cross/units/i386-win32/
156+ -Fu~/cross_fpc/lib/fpc/$fpcversion/cross/units/i386-win32/*
157+ -Fu~/cross_fpc/lib/fpc/$fpcversion/cross/units/i386-win32/rtl
158+ -XPi686-mingw32-
159+ -FD~/cross_fpc/cross/bin
160+ #ELSE linux
161+ -Fu/usr/lib/fpc/$fpcversion/units/$fpctarget
162+ -Fu/usr/lib/fpc/$fpcversion/units/$fpctarget/*
163+ -Fu/usr/lib/fpc/$fpcversion/units/$fpctarget/rtl
164+ #-Fu~/fpc/packages/*;~/fpc/rtl/linux
165+ #ENDIF
166+```
136167
137-Infine: Testare e risolvere gli eventuali problemi
168+Infine: Testare e risolvere gli eventuali problemi
138169
139170### Compilazione multipiattaforma dell'LCL e dei componenti lazarus
140171
141-Sulla linea di comando:
142-
143-`cd lazarus; make clean all OS_TARGET=win32`\
144-`cd lazarus/lcl; make clean all `
172+Sulla linea di comando:
173+```
174+cd lazarus; make clean all OS_TARGET=win32
175+ cd lazarus/lcl; make clean all
176+```
145177
146-Questo compilerà tutti i file per win32 (incluso l'IDE, che non è necessario, ma questo semplifica il tutto)
178+Questo compilerà tutti i file per win32 (incluso l'IDE, che non è necessario, ma questo semplifica il tutto)
147179
148-O nell'IDE: impostare LCL, Synedit, Codetools, Package Registration e IDE Interface a Clean+Build, impostare LCL interface a win32/win64 ed impostare 'Target OS' a win32. Quindi 'build lazarus'.
180+O nell'IDE: impostare LCL, Synedit, Codetools, Package Registration e IDE Interface a Clean+Build, impostare LCL interface a win32/win64 ed impostare 'Target OS' a win32. Quindi 'build lazarus'.
149181
150-These four parts have splitted output directories, so your linux .ppu/.o files are *not* overwritten and you don't need to recompile them.
182+These four parts have splitted output directories, so your linux .ppu/.o files are *not* overwritten and you don't need to recompile them.
151183
152184### Cross compiling a project
153185
154-Set in Project-\>Compiler Options-\>Code the Target OS to 'win32' and in Paths the 'LCL Widget Type' to win32. That's all. The next time you build, you will create a win32 executable. The IDE will rescan for win32 units, so that 'Find declaration' and code completion features will now work with the win32 rtl instead of the linux rtl. When you open another project or reopen this project the IDE will automatically switch.
186+Set in Project->Compiler Options->Code the Target OS to 'win32' and in Paths the 'LCL Widget Type' to win32. That's all. The next time you build, you will create a win32 executable. The IDE will rescan for win32 units, so that 'Find declaration' and code completion features will now work with the win32 rtl instead of the linux rtl. When you open another project or reopen this project the IDE will automatically switch.
155187
156188### Hints for Cross compiling and Lazarus
157189
158-If you create an application/package for multiple targets, you will often do the following: Fix a bug, compile and test it under linux, then compile and test it under win32, .. . Because normally you overwrite your .ppu files, you have to recompile everything, everytime you switch. This is not necessary. The Lazarus IDE supports macros.
190+If you create an application/package for multiple targets, you will often do the following: Fix a bug, compile and test it under linux, then compile and test it under win32, .. . Because normally you overwrite your .ppu files, you have to recompile everything, everytime you switch. This is not necessary. The Lazarus IDE supports macros.
159191
160-Example 1: Cross compiling a project for linux and win32.
192+Example 1: Cross compiling a project for linux and win32.
161193
162-Set Project -\> Compiler Options -\> Paths -\> Unit Output directory to \$(TargetOS). This macro will be replaced by the value in Code -\> TargetOS in lowercase (i.e. "linux" for Linux and "win32" for Win32). The output directory is relative to your project directory (the directory where your .lpi is). Create a linux and win32 directory in your project directory. When you click on the "Show Options" button at the bottom of the compiler options, you will see a -FElinux/ or -FEwin32/. This option tells the compiler where to write the output (e.g. .ppu/.o files).
194+Set Project -> Compiler Options -> Paths -> Unit Output directory to $(TargetOS). This macro will be replaced by the value in Code -> TargetOS in lowercase (i.e. "linux" for Linux and "win32" for Win32). The output directory is relative to your project directory (the directory where your .lpi is). Create a linux and win32 directory in your project directory. When you click on the "Show Options" button at the bottom of the compiler options, you will see a -FElinux/ or -FEwin32/. This option tells the compiler where to write the output (e.g. .ppu/.o files).
163195
164-Example 2: Cross compiling a project for various platforms and widget sets.
196+
197+Example 2: Cross compiling a project for various platforms and widget sets.
165198
166-Set the Unit output directory to \$(TargetCPU)/\$(TargetOS)/\$(LCLWidgetType) and create the sub directories for all targets. This path construction is also used by the LCL.
199+Set the Unit output directory to $(TargetCPU)/$(TargetOS)/$(LCLWidgetType) and create the sub directories for all targets. This path construction is also used by the LCL.
167200
168-The same can be done for packages.
201+
169202
203+The same can be done for packages.
204+
170205### Cross compiling and Lazarus Packages
171206
172-Lazarus packages are not limited to libraries. They can be used to compile nearly everything. And the IDE automatically recompiles them if needed. Packages can inherit compiler options. For example: A project that uses a package inherits the output directory of the package. In other words: the output directory of the package is added to unit search path of the project. See in the IDE: Project -\> Compiler options -\> Inherited. Inheritance normally works only one way. But there are exceptions: The target platform (OS and CPU) of the project overrides the target for all used packages. That means, if you set the Target OS of the project to "win32" and compile the project, the IDE will check if the used packages need to be recompiled for this Target OS.
207+Lazarus packages are not limited to libraries. They can be used to compile nearly everything. And the IDE automatically recompiles them if needed. Packages can inherit compiler options. For example: A project that uses a package inherits the output directory of the package. In other words: the output directory of the package is added to unit search path of the project. See in the IDE: Project -> Compiler options -> Inherited. Inheritance normally works only one way. But there are exceptions: The target platform (OS and CPU) of the project overrides the target for all used packages. That means, if you set the Target OS of the project to "win32" and compile the project, the IDE will check if the used packages need to be recompiled for this Target OS.
173208
174-For example:
209+For example:
175210
176-Package A has as output directory: lib/\$(TargetOS) Project uses A.
211+Package A has as output directory: lib/$(TargetOS) Project uses A.
177212
178-1. The project is built for linux. The IDE compiles A for linux in \<PackageDirOfA\>/lib/linux/, then it compiles the project for linux.
179-2. The project is built for win32. The IDE compiles A for win32 in \<PackageDirOfA\>/lib/win32/, then it compiles the project for win32.
180-3. The project is built again for linux. The IDE checks A for linux and does not recompile it. Then it compiles the project for linux.
213+ 1. The project is built for linux. The IDE compiles A for linux in <PackageDirOfA>/lib/linux/, then it compiles the project for linux.
214+ 2. The project is built for win32. The IDE compiles A for win32 in <PackageDirOfA>/lib/win32/, then it compiles the project for win32.
215+ 3. The project is built again for linux. The IDE checks A for linux and does not recompile it. Then it compiles the project for linux.
181216
182-So, using the macros saves a lot of time.
217+So, using the macros saves a lot of time.
183218
184219## For Unix (general)
185220
186-Option -XLA is used to rename library dependencies specified in pascal units. Format is -XLAold=new, to modify ld link option -l\<old\> to -l\<new\>.
221+Option -XLA is used to rename library dependencies specified in pascal units. Format is -XLAold=new, to modify ld link option -l<old> to -l<new>.
187222
188-Option -XR\<sysroot\> (recent trunk) that can be used to specify the target system root. It's used for:
223+Option -XR<sysroot> (recent trunk) that can be used to specify the target system root. It's used for:
189224
190-- adding a prefix to the default added library paths; in the past you used to specify -Xd and these paths manually. E.g. for i386-linux instead of passing /lib, /usr/lib, and /usr/X11R6/lib to ld, it will pass \<sysroot\>/lib, \<sysroot\>/usr/lib, and \<sysroot\>/usr/X11R6/lib to ld.
191-- detecting the C library (linux specific): glibc or uclibc. E.g. for uclibc detection '\<sysroot\>/lib/ld-uClibc.so.0' is tried.
225+ * adding a prefix to the default added library paths; in the past you used to specify -Xd and these paths manually. E.g. for i386-linux instead of passing /lib, /usr/lib, and /usr/X11R6/lib to ld, it will pass <sysroot>/lib, <sysroot>/usr/lib, and <sysroot>/usr/X11R6/lib to ld.
226+ * detecting the C library (linux specific): glibc or uclibc. E.g. for uclibc detection '<sysroot>/lib/ld-uClibc.so.0' is tried.
192227
193228## Per Linux sotto Win32
194229
195230É possibile reperire su tale argomento (meno importante del precedente) alcune informazioni nelle [[buildfaq]]
196231
197232## FreeBSD to sparc
198233
199-I managed to crosscompile from x86 to Sparc Solaris 9. However the result doesn't work very well, but here is my cmdline:
200-
201-in compiler/ execute:
202-
203-` gmake cycle CPU_TARGET=sparc OS_TARGET=solaris CROSSBINUTILPREFIX=solaris-sparc- CROSSOPT='-Xd -Fl~/src/sollib'`
234+I managed to crosscompile from x86 to Sparc Solaris 9. However the result doesn't work very well, but here is my cmdline:
204235
205-~/src/sollib is a directory that contains:
236+in compiler/ execute:
237+```
238+gmake cycle CPU_TARGET=sparc OS_TARGET=solaris CROSSBINUTILPREFIX=solaris-sparc- CROSSOPT='-Xd -Fl~/src/sollib'
239+```
206240
207-- a set of .o's from /usr/local/gcc-3.3-32bit/lib/gcc-lib/sparc-sun-solaris/3.3
208-- libgcc.a from /usr/local/gcc-3.3-32bit/lib/gcc-lib/sparc-sun-solaris/3.3
209-- a set of lib*.so from /usr/lib: libaio.so libmd5.so libc.so libelf.so librt.so libdl.so libm.so
241+~/src/sollib is a directory that contains:
210242
211-Problem is illustrated by the following binary.
243+ * a set of .o's from /usr/local/gcc-3.3-32bit/lib/gcc-lib/sparc-sun-solaris/3.3
244+ * libgcc.a from /usr/local/gcc-3.3-32bit/lib/gcc-lib/sparc-sun-solaris/3.3
245+ * a set of lib*.so from /usr/lib: libaio.so libmd5.so libc.so libelf.so librt.so libdl.so libm.so
212246
213-` Free Pascal Compiler version 2.1.1 [2006/03/17] for sparc`\
214-` Copyright (c) 1993-2005 by Florian Klaempfl`\
215-` Target OS: Solaris for SPARC`\
216-` Compiling system.pp`\
217-` system.pp(15,1) Fatal: Syntax error, "BEGIN" expected but "identifier UNIT" found`
247+Problem is illustrated by the following binary.
248+```
249+Free Pascal Compiler version 2.1.1 [2006/03/17] for sparc
250+ Copyright (c) 1993-2005 by Florian Klaempfl
251+ Target OS: Solaris for SPARC
252+ Compiling system.pp
253+ system.pp(15,1) Fatal: Syntax error, "BEGIN" expected but "identifier UNIT" found
254+```
218255
219-I suspect wrong .o's are taken.
256+I suspect wrong .o's are taken.
220257
221258## Per Mac OS X
222259
223-Si veda [forum post](http://www.lazarus.freepascal.org/index.php?name=PNphpBB2&file=viewtopic&p=7222#7222).
260+Si veda [forum post](<http://www.lazarus.freepascal.org/index.php?name=PNphpBB2&file=viewtopic&p=7222#7222>).
224261
225262## Contributi Originali
226263
227-Questa pagina è una traduzione dall'inglese di [Cross compiling for Win32 under Linux](http://wiki.lazarus.freepascal.org/Cross_compiling_for_Windows_under_Linux).
264+Questa pagina è una traduzione dall'inglese di [[Cross compiling for Windows under Linux|Cross compiling for Win32 under Linux]].
228265
229266---
230-*From the Free Pascal wiki, page "Cross compiling for Win32 under Linux/it", as it stood on 2021-07-20 after a change by Dbannon, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's [[Licensing]] page. If you have concerns about this material, [message the admin](/wiki-contact).*
267+*From the Free Pascal wiki, page "Cross compiling for Win32 under Linux/it", as the Internet Archive kept it on 2022-08-14. Copyright stays with the author who wrote it, according to the old wiki's [[Licensing]] page. If you have concerns about this material, [message the admin](/wiki-contact).*

Back to history