Forum > Operating Systems

Is cross compiling just a theory ?

(1/2) > >>

brudjuz:
I work on Ubuntu 12.10 64bit OS and Lazarus 1.0.5 64bit from http://ppa.launchpad.net/prof7bit/lazarus-1.0-latest/ubuntu.

I have been read many topics from this forum about cross compiling and Lazarus Wiki - but without successfull implementation.

I'm trying to compile project for Win32 or Win64. In meantime, I use VirtualBox with Windows 7 Professional 32bit for generating 32bit exe.

Does anybody have real Linux solution or cross compiling is just a theory ?

BigChimp:
Try CodeTyphon; don't know if it is available for linux but it apparently has cross-compiling set up out of the box.

Apart from that, yes many people cross-compile. It might help if you say what article exactly you read and where it went wrong. No crystal balls here.

brudjuz:
I'm trying to compile project for Win32 (or Win64) from official Lazarus 1.0.5 64bit in Ubuntu 12.10 64bit environment...

Error message from Lazarus is :
Compiler "/usr/bin/fpc" does not support target x86_64-win32.

What else I have to setup ?

Leledumbo:

--- Quote ---Does anybody have real Linux solution or cross compiling is just a theory ?
--- End quote ---
Of course not, how do you think FPC gets ported in the first place if not by cross compiling? What you have to understand is that it doesn't work out of the box, you have to understand some things.

* The real compiler, ppcXXX, where XXX refers to the platform it is compiled on, is a cross compiler for all OS of the same architecture. That means, on a x86 machine, ppc386 can be used to compile for i386-win32, i386-linux, etc.
* For different architecture, one must build the cross compiler from source (if it's not provided already). The compiler name will have additional 'ross' before the target platform. E.g., if the target platform is arm, then the cross compiler name would be ppcrossarm.
* Units compiled for one target WILL NOT WORK for other targets, one must recompile all required units in order to build a working program, the compiler itself IS NOT ENOUGH.
* Other than the compiler, one also needs binutils for platforms whose assembler and linker is not yet available internally in the compiler. Currently, the compiler only has internal assembler for x86 and x86-64, and the internal linker only for Win32/64 (Linux internal linker is on the way).
* If you have understood all the concepts, you can start building a cross environment setup by building from source using:

make all OS_TARGET=<your target os> CPU_TARGET=<your target cpu>

For arm-linux target, it will be: make all OS_TARGET=linux CPU_TARGET=arm
Note that at this step you already need the binutils. If everything goes well, execute:

make crossinstall OS_TARGET=<your target os> CPU_TARGET=<your target cpu> INSTALL_PREFIX=<target dir>

for linux, you can put your native FPC install dir as target dir, they will not interfere with existing installation and you can have single config file for all of them.For my own needs, I've built a bash script to help me building all cross targets I need. Search the forum for another cross compiling topics, I've attached the script there (my current script is different from the last one I attach due to partition management change on my machine, and the change would cause it not to work on typical machine).

--- Quote ---What else I have to setup ?
--- End quote ---
Clearly you skim too much on the topics you've seen and the wiki article. What I said above is more or less already mentioned there.

brudjuz:
Thank you.

If I understand, I must build Lazarus from SVN trunk with make directives that you suggested...

Navigation

[0] Message Index

[#] Next page

Go to full version