Hi,
What can the 32bit FPC compiler (currently I run under Linux) cross-compile to 32bit Windows or 64bit Linux. But the 64bit FPC (Linux) can only cross-compile to other 64bit platforms. Why not 32bit platforms too?
Regards,
- Graeme -

Mailing lists / fpc-pascal / 2009-11
17 messages · 6 people ·
Reply by email Subscribe to this list Your subscription
Read-only archive. Use j and k to move between messages.
Hi,
What can the 32bit FPC compiler (currently I run under Linux) cross-compile to 32bit Windows or 64bit Linux. But the 64bit FPC (Linux) can only cross-compile to other 64bit platforms. Why not 32bit platforms too?
Regards,
- Graeme -
Graeme Geldenhuys wroteHi, What can the 32bit FPC compiler (currently I run under Linux) cross-compile to 32bit Windows or 64bit Linux.
Do you mean that ppcx64 can generate code for win32? I don't think that is true.
But the 64bit FPC (Linux) can only cross-compile to other 64bit platforms. Why not 32bit platforms too?
A ppcXXX compiler can generate code for one specific CPU. The ppcx64 is for amd64 and ppc386 is for 32 bits intel (80386 - Pentium - and compatibles).
Vincent
What can the 32bit FPC compiler (currently I run under Linux) cross-compile to 32bit…
It can, i've successfully managed to cross-compile to 32-bit linux and 32-bit windows on the same 64-bit linux machine. (that includes the FPC itself and Lazarus)
There is a guide on the wiki here:
http://wiki.freepascal.org/Cross_compiling
Kind regards,
Torsten Bonde Christiansen.
Do you mean that ppcx64 can generate code for win32? I don't think that is true. A ppcXXX…
See the output below. The 32bit Linux FPC can target 32bit & 64bit platforms. But 64bit Linux FPC cannot target 32bit platforms. The later can only cross-compile to other 64bit platforms.
----------------------
$ ppcx64 -i
Free Pascal Compiler version 2.3.1
Compiler Date : 2009/10/22
Compiler CPU Target: x86_64
Supported targets:
Linux for x86-64
FreeBSD for x86-64
Win64 for x64
Darwin for x86_64
----------------------
----------------------
./ppc386 -i
Free Pascal Compiler version 2.2.5
Compiler Date : 2009/05/28
Compiler CPU Target: i386
Supported targets:
GO32 V2 DOS extender
Linux for i386
OS/2
Win32 for i386
FreeBSD/ELF for i386
Solaris for i386 (under development)
Beos for i386 (under development)
NetBSD for i386 (under development)
Netware for i386(clib)
WDOSX DOS extender
OpenBSD for i386 (under development)
OS/2 via EMX
Watcom compatible DOS extenders
Netware for i386(libc)
WinCE for i386
Linux for x64_6432
Darwin for i386
Symbian OS for i386
----------------------
I'm new to supporting multiple compiler versions and now to add cross-compilers to the mix. I don't know how I am supposed to structure my directory layout or ~/.fpc.cfg file. Currently I have the following layout.
/opt/
.
|-fpc_2.2.5
|--- bin
|--- lib
|--- share
|--- src
|-fpc_2.3.1
|--- bin
|--- lib
|--- share
|--- src
|-fpc_2.5.1
|--- bin
|--- lib
|--- share
|--- src
Example: When I compile a new 64-bit FPC 2.2.5 I do the following.
cd fpc_<ver>/src
make clean PP=/opt/fpc_2.2.5/bin/ppcx64
make all PP=/opt/fpc_2.2.5/bin/ppcx64
make install INSTALL_PREFIX=/opt/fpc_2.2.5 \
PP=/opt/fpc_2.2.5/bin/ppcx64
I then do similar for other FPC versions too. The only problem being that the 'bin' directory gets overwritten, so maybe I need to install into a different directory for each version. Like this:
INSTALL_PREFIX=/opt/fpc_2.2.5/64bit_linux
INSTALL_PREFIX=/opt/fpc_2.2.5/32bit_linux
INSTALL_PREFIX=/opt/fpc_2.2.5/32bit_windows <- cross-compiler
Regards,
- Graeme -
Graeme Geldenhuys wroteSee the output below. The 32bit Linux FPC can target 32bit & 64bit platforms. But 64bit Linux FPC cannot target 32bit platforms. The later can only cross-compile to other 64bit platforms.
I guess you mean this:
[snip]
Linux for x64_6432
x64_6432 is not the same as x64_64. It means, afaik, a 32 bit binary running on a 64 bit Linux system. It probably changes some default library search paths or so. The i386 compiler cannot generate x86_64 binaries. The appropriate code generator is simply not available.
Jonas
Ah yes. Sorry, I did not notice the '32' at the end.
library search paths or so. The i386 compiler cannot generate x86_64 binaries. The appropriate code generator is simply not available.
Ummm... I'll go read the wiki and buildfaq again. I'm a bit confused though. When I switched computers and moved from 32bit Linux to 64bit Linux, I used my 32bit Linux FPC 2.2.5 and cross-compiled a "what I thought was a 64bit FPC", and have been using that ever since as my 64bit FPC?
So how is what I am using now, not a 64bit FPC? Linux seems to report in correctly as 64bit? Below is what I was left with after I did the cross-compile from 32 -> 64 bit.
$ file /opt/fpc_2.2.5/bin/fpc
fpc: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), statically linked, for GNU/Linux 2.4.0, not stripped
$ file /opt/fpc_2.2.5/lib/fpc/2.2.5/ppcx64
/opt/fpc_2.2.5/lib/fpc/2.2.5/ppcx64: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), statically linked, for GNU/Linux 2.4.0, not stripped
Regards,
- Graeme -
When you compile a compiler, there are three platforms that come into play:
a) the platform on which you are compiling the new compiler b) the platform on which you want to run the new compiler c) the platform for which the new compiler should generate code
For the Linux/i386 compiler that we ship a = b = c = Linux/i386. With this compiler, you can however compile a compiler that ,e.g., runs on Linux/i386, but that generates code for x86_64 (it will be called ppcrossx64, and as the name implies it's a cross compiler)). And with this second compiler you can then compile a compiler that both runs on x86_64 and generates x86_64 (called ppcx64).
If you do a "make all CPU_TARGET=x86_64" in the FPC directory on a Linux/i386 platform, then the Makefile will automatically first compile a cross-compiler to x86_64 and then a native compiler for and to x86_64.
Jonas
I guess you mean this: [snip] x64_6432 is not the same as x64_64. It means, afaik, a 32…
Is it possible to create an .exe file at linux os when choosing target 'windows'?
If I change on a linux os the target to windows there is a message 'the system.ppu was not found in the FPC directories. ...'
Sorry if I did not read the thread exactly...
When you compile a compiler, there are three platforms that come into play: a) the…
Thanks for explaining that Jonas. It's much clearer now. What is listed above is probably what I did, and that is how I ended up with a true ppcx64 executable for FPC 2.2.5.
Regards,
- Graeme -
Is it possible to create an .exe file at linux os when choosing target 'windows'? If I…
Rainer Stratmann wroteIs it possible to create an .exe file at linux os when choosing target 'windows'?
Yes - when you compile your applications using the cross compiler. The crosscompiler wiki page explains it all. I have successfully created Windows 32bit .exe files from my Linux system.
NOTE:
The cross compiler (ppcross386) is still a Linux executable though, but the project compiled with that compiler is a native Windows executable.
Pretty neat! :-)
Regards,
- Graeme -
You don't need a cross compiler for that. An FPC binary can only generate code for a single target processor, but it always supports all operating systems supported by FPC on that target processor.
What you do need, are
a) possibly helper utilities for that target system (assembler, linker, resource compiler, ... -- for win32 that's not necessary, as everything is built into the compiler already)
b) a compiled version of all rtl and packages units for that target
Jonas
I got Lazarus on a debian netinst system with this script:
#!/bin/sh
gpg --keyserver hkp://pgp.mit.edu:11371 --recv-keys 6A11800F gpg --export 6A11800F | apt-key add -
echo "deb http://www.hu.freepascal.org/lazarus/ lazarus-stable universe" \
/etc/apt/sources.list.d/lazarus.list
apt-get update
apt-get install lazarus
Is it possible to get the files you mentioned with a similar easy method?
If your source os and cpu is i386-linux and your target is i386-win32, then you get the fpc-crosswin32 deb package from that location.
Vincent
I can not find such a package there..., rgds Rainer
I guess you mean this: [snip] x64_6432 is not the same as x64_64. It means, afaik, a 32…
x64_6432 is a special target for a hacked 32 bit mode: it allows to use the extended register set of x86_64 in 32 bit mode.
I can not find such a package there..., rgds Rainer
Rainer Stratmann wrote> If your source os and cpu is i386-linux and your target is i386-win32, > then you get the fpc-crosswin32 deb package from that location. I can not find such a package there..., rgds Rainer
Well, it is there:
http://www.hu.freepascal.org/lazarus/dists/lazarus-stable/universe/binary-i386/fpc_crosswin32_2.2.4-091003_i386.deb
Vincent
Yes, it works! Thanks.
That means, from the deb packages on this page it is also possible to install the fpc compiler and the lazarus ide? Rainer
Vincent _______________________________________________ fpc-pascal maillist - http://lists.freepascal.org/mailman/listinfo/fpc-pascal