Recent

Author Topic: Compiling Linux project to Windows platform  (Read 2959 times)

pascal111

  • Sr. Member
  • ****
  • Posts: 423
  • Un trabajo en equipo para programas serias.
Compiling Linux project to Windows platform
« on: April 18, 2021, 12:41:49 am »
Hello everyone!

I'm Linux Mint user, and I'm a beginner generally to Pascal language and particularly to Lazarus IDE. I succeeded to convert some traditional BASIC command-line games into Lazarus freePascal, and some other users who are using Windows like to try these small games, but I didn't understand the idea how to compile the projects to Windows exe files.

I googled for this topic and found this document but I didn't get the idea how to do it on my installed Lazarus, I didn't find same folders with the same names in my Lazarus version.

https://wiki.lazarus.freepascal.org/Cross_compiling_for_Win32_under_Linux
La chose par la chose est rappelé.

trev

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2020
  • Former Delphi 1-7, 10.2 user
Re: Compiling Linux project to Windows platform
« Reply #1 on: April 18, 2021, 01:39:34 am »
Have you done the two steps described in this step on the Wiki page you cited?

dbannon

  • Hero Member
  • *****
  • Posts: 2786
    • tomboy-ng, a rewrite of the classic Tomboy
Re: Compiling Linux project to Windows platform
« Reply #2 on: April 18, 2021, 06:55:51 am »
 > I didn't find same folders with the same names in my Lazarus version.

OK, firstly, please understand when you are setting up a cross compiler, its FPC stuff you are doing, at least initially. Lazarus does not come into it until you start using the cross compiler.  So, by saying that you cannot find the "same names", you probably mean the FPC folder names ? Please tell us what names you are looking for ?

My one notes as to how I setup my cross compilers say this -
Code: [Select]
# Setup 32bit and 64 bit Windows
cd /usr/share/fpcsrc/$FPCVER
make clean all OS_TARGET=win32 CPU_TARGET=i386
make crossinstall OS_TARGET=win32 CPU_TARGET=i386 INSTALL_PREFIX=/usr
ln -sf /usr/lib/fpc/$FPCVER/ppcross386 /usr/bin/ppcross386

make clean all OS_TARGET=win64 CPU_TARGET=x86_64
make crossinstall OS_TARGET=win64 CPU_TARGET=x86_64 INSTALL_PREFIX=/usr
ln -sf /usr/lib/fpc/$FPCVER/ppcrossx64 /usr/bin/ppcrossx64

# Make sure its all there (we should see ppcross386, ppcrossx64)
echo "watch for ppcross386, ppcrossx64"
ls -la /usr/lib/fpc/$FPCVER/ppcross*
ls -la /usr/bin/ppcross*

The wiki does not seem as complete as my notes, strange as they were based on the wiki some time ago.  Please step through those notes, watching carefully for an error message and tell us what you find.  If it works as I expect it to, I better update the wiki (I am unsure because I don't use a deb installed FPC anymore and I assume you, and most new users will).

If you do have a deb installed FPC (either Mint repo of SourceForge) your FPC is installed in root space, that means, sadley, you need to run the compiler build as root, otherwise you will not be able to save files in the right place.

Mint will probably have an older FPC in its repos (based on Ubuntu 18.04 from memory) and thats likely to be 3.0.4, maybe you should consider updating to FPC 3.2.0 but its not critical. (Installing FPC from a Tarball and Lazarus from source ends up with all you code in user space and does make life a little easier).

Please let us know how it all goes.

Davo
Lazarus 3, Linux (and reluctantly Win10/11, OSX Monterey)
My Project - https://github.com/tomboy-notes/tomboy-ng and my github - https://github.com/davidbannon

pascal111

  • Sr. Member
  • ****
  • Posts: 423
  • Un trabajo en equipo para programas serias.
Re: Compiling Linux project to Windows platform
« Reply #3 on: April 18, 2021, 03:16:49 pm »
I found this error when I tried to do the same like the wiki page instructions:

Code: Pascal  [Select][+][-]
  1. pascal@pascal-Lenovo-ideapad-330-15AST:~$ cd /usr/share/fpcsrc/3.0.4
  2. pascal@pascal-Lenovo-ideapad-330-15AST:/usr/share/fpcsrc/3.0.4$ sudo make clean all OS_TARGET=win32 CPU_TARGET=i386
  3. [sudo] password for pascal:                  
  4. make: *** No rule to make target 'clean'.  Stop.
  5. pascal@pascal-Lenovo-ideapad-330-15AST:/usr/share/fpcsrc/3.0.4$
  6.  
La chose par la chose est rappelé.

trev

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2020
  • Former Delphi 1-7, 10.2 user
Re: Compiling Linux project to Windows platform
« Reply #4 on: April 19, 2021, 01:47:09 am »
Odd. What is the output of this command in the 3.0.4 directory:

Code: Text  [Select][+][-]
  1. $ grep -i ^clean Makefile

dbannon

  • Hero Member
  • *****
  • Posts: 2786
    • tomboy-ng, a rewrite of the classic Tomboy
Re: Compiling Linux project to Windows platform
« Reply #5 on: April 19, 2021, 01:47:22 am »
Says https://wiki.freepascal.org/Installing_Lazarus_on_Linux
Some distro prepared packages do not include the tools necessary to add cross compiling to its capabilities. If you may want to cross compile in the future, please consider one of the next listed models.

Looks like yours does not have the make file there, it should have but distribution repo maintainers build a package to meet the declared need, not provide the flexability you need if you are to do something just a bit out unexpected. Sigh.

While you can probably build that Makefile your self, I suspect you might find it easier in the long run if you install an up to date FPC, please see - https://wiki.lazarus.freepascal.org/Installing_the_Free_Pascal_Compiler#Linux

I suggest you remove the existing FPC first, leave the dependencies there (or manually reinstall them) and then install FPC320, either a a deb from https://sourceforge.net/projects/lazarus/files/ or, a bit harder and a bit better, install a tar ball in your own (as opposed to root's) disk space.

;D Then, when you have a proper FPC, take the next step and install Lazarus from source.  I am a big fan of developers knowing where all their tools are, being able to fiddle with the code easily. Join us, do not be afraid, you will be assimilated ....)

Davo

Lazarus 3, Linux (and reluctantly Win10/11, OSX Monterey)
My Project - https://github.com/tomboy-notes/tomboy-ng and my github - https://github.com/davidbannon

dbannon

  • Hero Member
  • *****
  • Posts: 2786
    • tomboy-ng, a rewrite of the classic Tomboy
Re: Compiling Linux project to Windows platform
« Reply #6 on: April 19, 2021, 01:49:26 am »
Odd. What is the output of this command in the 3.0.4 directory:

No, not that odd, distribution packages are not intended to be 'extended' like we do when we add cross compiling.

Davo
Lazarus 3, Linux (and reluctantly Win10/11, OSX Monterey)
My Project - https://github.com/tomboy-notes/tomboy-ng and my github - https://github.com/davidbannon

pascal111

  • Sr. Member
  • ****
  • Posts: 423
  • Un trabajo en equipo para programas serias.
Re: Compiling Linux project to Windows platform
« Reply #7 on: April 19, 2021, 01:16:00 pm »
Odd. What is the output of this command in the 3.0.4 directory:

Code: Text  [Select][+][-]
  1. $ grep -i ^clean Makefile

Code: Text  [Select][+][-]
  1. pascal@pascal-Lenovo-ideapad-330-15AST:/usr/share/fpcsrc/3.0.4$ grep -i ^clean Makefile
  2. grep: Makefile: No such file or directory
  3. pascal@pascal-Lenovo-ideapad-330-15AST:/usr/share/fpcsrc/3.0.4$
  4.  
  5.  
La chose par la chose est rappelé.

pascal111

  • Sr. Member
  • ****
  • Posts: 423
  • Un trabajo en equipo para programas serias.
Re: Compiling Linux project to Windows platform
« Reply #8 on: April 19, 2021, 01:23:01 pm »
Says https://wiki.freepascal.org/Installing_Lazarus_on_Linux
Some distro prepared packages do not include the tools necessary to add cross compiling to its capabilities. If you may want to cross compile in the future, please consider one of the next listed models.

Looks like yours does not have the make file there, it should have but distribution repo maintainers build a package to meet the declared need, not provide the flexability you need if you are to do something just a bit out unexpected. Sigh.

While you can probably build that Makefile your self, I suspect you might find it easier in the long run if you install an up to date FPC, please see - https://wiki.lazarus.freepascal.org/Installing_the_Free_Pascal_Compiler#Linux

I suggest you remove the existing FPC first, leave the dependencies there (or manually reinstall them) and then install FPC320, either a a deb from https://sourceforge.net/projects/lazarus/files/ or, a bit harder and a bit better, install a tar ball in your own (as opposed to root's) disk space.

;D Then, when you have a proper FPC, take the next step and install Lazarus from source.  I am a big fan of developers knowing where all their tools are, being able to fiddle with the code easily. Join us, do not be afraid, you will be assimilated ....)

Davo


I'm in the stage of learning the language, so I don't see it's good to let any stone through the raod makes me late, so if I failed to gain the feature of converting my projects into Windows exe's with my current version of Lazarus, I'll leave it to do it later in another time after mastering the language. The suggested solutions to install Lazarus again may be failed, I'm not sure to succeed and I'll open another door of queries about how to fix Lazarus install from .tar file or external package, so we will be late more about our aim which is learning and mastering the programming.
La chose par la chose est rappelé.

Zvoni

  • Hero Member
  • *****
  • Posts: 2319
Re: Compiling Linux project to Windows platform
« Reply #9 on: April 19, 2021, 01:53:10 pm »
Or use fpcupdeluxe (see Third Party Forum here)
It's what i use to install FPC/Lazarus on my Manjaro-Machine incl. crosscompiler for Windows and Mac

As a general rule of thumb:
As davo mentioned: Don't ever use pre-packaged versions from distro-repos.
When i was still on Ubuntu it cost me a lot of time to get my broken install fixed.
Ended up removing it completely, and then re-installing it using fpcupdeluxe.
OTOH, IIRC fpcupdeluxe doesn't resolve dependencies, so those have to be installed first (libqt5pas comes to mind)
Never looked back
One System to rule them all, One Code to find them,
One IDE to bring them all, and to the Framework bind them,
in the Land of Redmond, where the Windows lie
---------------------------------------------------------------------
Code is like a joke: If you have to explain it, it's bad

kupferstecher

  • Hero Member
  • *****
  • Posts: 583
Re: Compiling Linux project to Windows platform
« Reply #10 on: April 19, 2021, 02:56:20 pm »
Zvoni's advice is good, use fpcupdeluxe for a second installation to do cross compilation. The good thing of fpcupdeluxe is it doesn't integrate the installation into the operating system (menues, file association etc) and thus leaves other installations untouched. So no need to worry that your primary installation is getting corrupted.

BUT... Crosscompilation without testing it on the target system I wouldn't recommend. Most likely it won't run in the first trial, just because a path is wrong, path delimiters, or the dimensions are (slightly but annoying) different. And if you can test it on a windows system, I would start by installing Lazarus there, directly.

devEric69

  • Hero Member
  • *****
  • Posts: 648
Re: Compiling Linux project to Windows platform
« Reply #11 on: April 19, 2021, 04:38:02 pm »
Hello. Zvoni's advice is good. Basically:
- use fpcUpDeluxe to install on the OS you want to cross-compile, Lazarus + fpc suited by your development machine (CPU+Linux).
- stay in fpcUpDeluxe, and then ask again, to install some others cross-compilers for other targeted OSes (CPU+Windows).

Then, you'll have to go in the project options, and change the target towards which you'll want to cross-compile alternately from your development machine.
« Last Edit: April 19, 2021, 04:41:27 pm by devEric69 »
use: Linux 64 bits (Ubuntu 20.04 LTS).
Lazarus version: 2.0.4 (svn revision: 62502M) compiled with fpc 3.0.4 - fpDebug \ Dwarf3.

pascal111

  • Sr. Member
  • ****
  • Posts: 423
  • Un trabajo en equipo para programas serias.
Re: Compiling Linux project to Windows platform
« Reply #12 on: April 20, 2021, 08:34:10 pm »
Ok gentlemen !

I see 3 suggestions for "fpcUpDeluxe". I think I'll have no door to invade to fix the current situation of my installed version, so, I'll use "fpcUpDeluxe" but later, but for now, I'll leave the idea of compiling Lazarus projects into Windows exe files via Linux platform. Any way, I compiled the games I made with another PC having Windows after downloading Lazarus Windows version, but it will be like a long solution for the problem, not a practical one.
La chose par la chose est rappelé.

 

TinyPortal © 2005-2018