Results 1 to 8 of 8

Thread: Cross-Compelation with Lazarus

  1. #1
    Co-Founder / PGD Elder WILL's Avatar
    Join Date
    Apr 2003
    Location
    Canada
    Posts
    6,107
    Blog Entries
    25

    Cross-Compelation with Lazarus

    I'm running Lazarus off of Windows XP and I'd like to make my cross-platform compatable project available on Linux and Mac OS X.

    This is the first time that I am doing this and want to know what considerations --as a brief rundown-- do I need to take while doing this under the latest Lazarus.

    Also, anyone interested in testing to see that I got it working? (it's my NS2 project that I have posted in the 'My Projects' forum)
    Jason McMillen
    Pascal Game Development
    Co-Founder





  2. #2

    Cross-Compelation with Lazarus

    - be careful with threads (in lazarus 9.14 the win32 code with tthread won't work on Linux)
    - remove everything that is windows (obvious but tricky as some things can be hidden in the code).

    And, of course, installing Lazarus on a Linux box is (compared to win32 install).. pain. But, if it's finally running it's stable.
    Marmin^.Style

  3. #3
    Co-Founder / PGD Elder WILL's Avatar
    Join Date
    Apr 2003
    Location
    Canada
    Posts
    6,107
    Blog Entries
    25

    Cross-Compelation with Lazarus

    Ok well those two don't seem to be a factor at this point, but good thing to note.

    There is however some issues reguarding this line of code which in Windows prevents the console window from poping up.
    [pascal]{$APPTYPE GUI} // FreePascal/Lazarus[/pascal]
    Alternative?

    AND it gives me an error saying:
    Quote Originally Posted by Messages
    NightStalker2.lpr(1,1) Fatal: Can't find unit System
    Here is my main program code's uses:
    [pascal]uses
    SysUtils,
    Math,

    sdl,
    sdlutils,
    sdl_mixer,

    // These are just my own units!
    NS2ConstantsUnit,
    NS2ObjectUnit,
    NS2FunctionsUnit,
    InputUnit,
    FontUnit,
    GraphicsUnit;[/pascal]
    Jason McMillen
    Pascal Game Development
    Co-Founder





  4. #4

    Cross-Compelation with Lazarus

    Cross-compiling from win32 to Linux is reasonably hard because you need the shared libraries you link to on your Windows system. Lazarus is not shipped with a Linux rtl, you must compile it yourself.

    {$APPTYPE GUI} is not necessary under Linux. You will get a warning if you try it, you either ignore the warning or {$fdef win32} it.

  5. #5
    Co-Founder / PGD Elder WILL's Avatar
    Join Date
    Apr 2003
    Location
    Canada
    Posts
    6,107
    Blog Entries
    25

    Cross-Compelation with Lazarus

    Ah! I see.... well thats something that would perhaps go on a requested features list no?

    So what is probably the easiest way to plug in the Linux RTL so that I may cross-compile?


    Oh and after setting this up at the top of my program's code I doubt I'll have more issues of that nature.

    [pascal]{$IFDEF Win32}
    {$IFDEF FPC}
    {$APPTYPE GUI} // FreePascal/Lazarus
    {$ELSE}
    {$APPTYPE CONSOLE} // Delphi
    {$ENDIF}
    {$ENDIF}[/pascal]
    Jason McMillen
    Pascal Game Development
    Co-Founder





  6. #6

    Cross-Compelation with Lazarus

    Quote Originally Posted by WILL
    Ah! I see.... well thats something that would perhaps go on a requested features list no?
    Perhaps with the internal ]
    So what is probably the easiest way to plug in the Linux RTL so that I may cross-compile?
    [/quote]

    Install the runtime library source code, use the makefile, and make the compiler point to the unit by the appriopriate command line options. There also a few threads about this on the Free Pascal forums, in case you need some help.

    Quote Originally Posted by WILL
    Oh and after setting this up at the top of my program's code I doubt I'll have more issues of that nature.
    I don't think so. Well, in 2.2 there will be Win64 and Windows define for the new win64 platform.

  7. #7
    Co-Founder / PGD Elder WILL's Avatar
    Join Date
    Apr 2003
    Location
    Canada
    Posts
    6,107
    Blog Entries
    25

    Cross-Compelation with Lazarus

    [quote="dmantione"]
    Quote Originally Posted by WILL
    Ah! I see.... well thats something that would perhaps go on a requested features list no?
    Perhaps with the internal ]

    Ah, but the internal linker is soon to replace the GNU one, no? :thumbup:

    Quote Originally Posted by dmantione
    Install the runtime library source code, use the makefile, and make the compiler point to the unit by the appriopriate command line options. There also a few threads about this on the Free Pascal forums, in case you need some help.
    Ok, I'll give this a go and let you know how I did.

    Quote Originally Posted by dmantione
    Quote Originally Posted by WILL
    Oh and after setting this up at the top of my program's code I doubt I'll have more issues of that nature.
    I don't think so. Well, in 2.2 there will be Win64 and Windows define for the new win64 platform.
    What will be the IFDEFs for those? Win64 and Windows?

    There obviously won't be one for 'Delphi', for obvious reasons.
    Jason McMillen
    Pascal Game Development
    Co-Founder





  8. #8

    Cross-Compelation with Lazarus

    [quote="WILL"]
    Ah, but the internal ]

    I hope so!

    Quote Originally Posted by WILL
    What will be the IFDEFs for those? Win64 and Windows?
    There obviously won't be one for 'Delphi', for obvious reasons.

    Yes, the defines will be called "win64" and "windows". It might be a good idea to write:
    Code:
    {$ifdef win32}
    {$define windows}
    {$endif}
    ... at top of your code and use {$ifdef windows} instead in the rest of your code, so it will already be compatible with win64.

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
  •