Bookstore

Recent

Author Topic: Is cross compiling just a theory ?  (Read 7088 times)

brudjuz

  • New member
  • *
  • Posts: 8
    • Open eXPerience Project
Is cross compiling just a theory ?
« on: February 02, 2013, 08:58:02 am »
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 ?
Poor is the man, whose pleasures depend on the permission of another...

BigChimp

  • Hero Member
  • *****
  • Posts: 5740
  • Add to the wiki - it's free ;)
    • FPCUp, PaperTiger scanning and other open source projects
Re: Is cross compiling just a theory ?
« Reply #1 on: February 02, 2013, 09:12:17 am »
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.
Want quicker answers to your questions? Read http://wiki.lazarus.freepascal.org/Lazarus_Faq#What_is_the_correct_way_to_ask_questions_in_the_forum.3F

Open source including papertiger OCR/PDF scanning:
https://bitbucket.org/reiniero

Lazarus trunk+FPC trunk x86, Windows x64 unless otherwise specified

brudjuz

  • New member
  • *
  • Posts: 8
    • Open eXPerience Project
Re: Is cross compiling just a theory ?
« Reply #2 on: February 02, 2013, 09:24:07 am »
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 ?
Poor is the man, whose pleasures depend on the permission of another...

Leledumbo

  • Hero Member
  • *****
  • Posts: 8159
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: Is cross compiling just a theory ?
« Reply #3 on: February 02, 2013, 09:32:58 am »
Quote
Does anybody have real Linux solution or cross compiling is just a theory ?
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 ?
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

  • New member
  • *
  • Posts: 8
    • Open eXPerience Project
Re: Is cross compiling just a theory ?
« Reply #4 on: February 02, 2013, 09:36:50 am »
Thank you.

If I understand, I must build Lazarus from SVN trunk with make directives that you suggested...
Poor is the man, whose pleasures depend on the permission of another...

Leledumbo

  • Hero Member
  • *****
  • Posts: 8159
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: Is cross compiling just a theory ?
« Reply #5 on: February 02, 2013, 09:50:39 am »
Quote
If I understand, I must build Lazarus from SVN trunk with make directives that you suggested...
Not Lazarus, but FPC