Recent

Author Topic: Can Project on Linux targeted to run On Windows?  (Read 563 times)

incendio

  • Jr. Member
  • **
  • Posts: 92
Can Project on Linux targeted to run On Windows?
« on: June 16, 2019, 06:42:26 am »
Hi guys,

I am using Lazarus on Linux Mint.

Can project build in Lazarus Linux compiled to run on Windows OS or it should compiled in Lazarus Windows?

I tried to compiled it in Linux with target OS Win32, but got an error.

Handoko

  • Hero Member
  • *****
  • Posts: 3188
  • My goal: build my own game engine using Lazarus
Re: Can Project on Linux targeted to run On Windows?
« Reply #1 on: June 16, 2019, 06:50:10 am »
Yes, Lazarus Linux can compile to get the binaries to run on Windows. I do not have Windows, I use Wine or my friend's Windows PC to test the binaries. It works.

This is my recipe to prepare the cross compiler:
# Cross Compile Win32
01. cd /usr/share/fpcsrc/
3.0.4
02. sudo make clean all OS_TARGET=win32 CPU_TARGET=i386
03. sudo make crossinstall OS_TARGET=win32 CPU_TARGET=i386 INSTALL_PREFIX=/usr
04. sudo ln -sf /usr/lib/fpc/
3.0.4/ppcross386 /usr/bin/ppcross386

You may need to change the text "3.0.4" to match your FPC version.

After you managed to build the cross compiler correctly, on your project option you need to select Win32 and i386.

incendio

  • Jr. Member
  • **
  • Posts: 92
Re: Can Project on Linux targeted to run On Windows?
« Reply #2 on: June 16, 2019, 07:54:54 am »
Hello,

Thanks a lot for your help. It worked fine.  :D


lucamar

  • Hero Member
  • *****
  • Posts: 2081
Re: Can Project on Linux targeted to run On Windows?
« Reply #3 on: June 16, 2019, 10:17:20 pm »
@Handoko: That's probably the simplest answer I've seen given to this question :)

Just one thing: Don't you need to compile also the LCL and Lazarus components? If so, any "as-easy-as" instructions?

I've been looking for something like this for ages, i.e. converting a normal installation into a cross-compiling one easily, but never dared risk my installations by dubious testing  :-[
Turbo Pascal 3 CP/M - Amstrad PCW 8256 (512 KB !!!) :P
Lazarus 2.0.2/2.0.4  - FPC 3.0.4 on:
(K|L)Ubuntu 12..16, Windows XP SP3, various DOSes.

dbannon

  • Hero Member
  • *****
  • Posts: 755
    • tomboy-ng, a rewrite of the classic Tomboy
Re: Can Project on Linux targeted to run On Windows?
« Reply #4 on: June 17, 2019, 01:39:30 am »
No Lucamar, no changes are needed to Lazarus itself. As long as it can find the appropriate compiler (ProjectOptions), it will build what it needs as it needs it. Very nice.

For the record, this will add a 64bit windows -
Code: Pascal  [Select]
  1. make clean all OS_TARGET=win64 CPU_TARGET=x86_64
  2. make crossinstall OS_TARGET=win64 CPU_TARGET=x86_64 INSTALL_PREFIX=/usr
  3. ln -sf /usr/lib/fpc/$FPCVER/ppcrossx64 /usr/bin/ppcrossx64

...And this will add 32bit linux (assuming we are on a 64bit platform) -
Code: Pascal  [Select]
  1. make all CPU_TARGET=i386
  2. make crossinstall CPU_TARGET=i386

But one thing I have noticed is that on three occasions now, Ubuntu has updated files in my /lib/i386-linux-gnu dir and left me with a broken symlink to libglib-2.0.so. That breaks the 32bit linux compile. So there is something unclean there ....

Davo


Lazarus 2, Linux (and reluctantly Win10, OSX)
My Project - https://github.com/tomboy-notes/tomboy-ng