Lazarus

Programming => Operating Systems => Topic started by: incendio on June 16, 2019, 06:42:26 am

Title: Can Project on Linux targeted to run On Windows?
Post by: incendio 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.
Title: Re: Can Project on Linux targeted to run On Windows?
Post by: Handoko 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.
Title: Re: Can Project on Linux targeted to run On Windows?
Post by: incendio on June 16, 2019, 07:54:54 am
Hello,

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

Title: Re: Can Project on Linux targeted to run On Windows?
Post by: lucamar 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  :-[
Title: Re: Can Project on Linux targeted to run On Windows?
Post by: dbannon 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


TinyPortal © 2005-2018