Results 1 to 6 of 6

Thread: Compiling Linux programs in Windows

  1. #1

    Compiling Linux programs in Windows

    Hi there.
    I tried to compile a sample program that displays "Hello world!" in FPC 2.0.2.
    Changed the Target to Linux-i386, and installed Linux units into FPC folder, in units/i386-linux
    The program compiled without errors, however I tried to run it in Linux, and I got "Permission denied" error. Then I changed file permissions with chmod, but still doesnt worked.


    After comparing the binary files of the programs, I noticed Linux native programs have ELF in their header, while the one I compiled got MZ, wich is the same as programs compiled to windows. Am I doing something wrong?
    Is there anyway to compile Linux programs under Windows using FPC?
    www.pascalgameengine.com - Crossplatform 3D game engine

  2. #2

    Compiling Linux programs in Windows

    Did you specify -Tlinux on the command line?

  3. #3

    Compiling Linux programs in Windows

    Yes, I already tried that.
    Compiles ok, but gives the following warning
    "ld.exe: cannot find entry simbol _mainCRTstartup; defaulting to 00401000"
    It seems that the FPC can only produce win32 binaries, changing the target doesnt seem to work. The final executable size is diferent from the win32 .exe, but doest run in Linux. Also if I change the file extension to .exe I able to run it in windows XP, but only console window appears, and then the program hangs.
    www.pascalgameengine.com - Crossplatform 3D game engine

  4. #4

    Compiling Linux programs in Windows

    You need a crosscompiler and cross binutils too. Look here for more infos.
    Get your fpc4gba copy now!
    Get your fpc4nds copy now!

  5. #5

    Compiling Linux programs in Windows

    Thanks for the info, I've already found some win32-linux cross compiler version of FPC. When I've some free time i'll test it.
    www.pascalgameengine.com - Crossplatform 3D game engine

  6. #6

    Compiling Linux programs in Windows

    Ok, I've tested it, and it worked
    If someone is interested in known how to do it, I will explain it.

    1A¬? Download the following BinUtils and extract it to your FPC\bin\i386-win32 folder:
    ftp://ftp.freepascal.org/pub/fpc/contrib/cross/cygwin/

    2A¬? Create a new folder FPC\units\i386-linux
    Download FPC (Linux version, the big .tar file) and extract all units there.

    3A¬? To compile your program (in the command line), do something like
    fpc.exe sample.pas -TLinux -XPi686-linux-

    The Cygwin cross binutils contains lots of files for diferente OS and processores, so probably this method can be used to compile to other targets, just install target units and change comand line arguments.
    www.pascalgameengine.com - Crossplatform 3D game engine

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •