Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2018-10

Cross-compile console program to Linux (Ubuntu)?

9 messages · 4 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Bo Berglund

I have a console program for Windows, which was developed using Delphi2007 and Indy10.
Now I need to port this to Linux (Ubuntu Server 16.04-3 LTS on Intel i386 CPu).
I have installed Lazarus 1.8.4-32 using the download from the official Lazarus site: lazarus-1.8.4-fpc-3.0.4-win32.exe

So I have Lazarus ver 1.8.4 and FPC ver 3.0.4 rev 57972 on my Windows 7 Pro X64 laptop.
I have also installed the IndyLaz package to get the Indy10 components and this works fine.

Given that what do I have to download in order to build the project for Ubuntu Linux on the Intel platform?
I am assuming that porting from Delphi2007 to Lazarus/FreePascal is OK...

Bo Berglund Developer in Sweden

Reply by email

Bo Berglund
to Bo Berglund: I have a console program for Windows, which was developed using Delphi2007 and Indy10.…
Bo Berglund wrote
So I have Lazarus ver 1.8.4 and FPC ver 3.0.4 rev 57972 on my Windows 7 Pro X64 laptop. I have also installed the IndyLaz package to get the Indy10 components and this works fine.

It turns out that this is false information!
This version of FPC/Lazarus has not yet been provided with IndyLaz package. And I need OnLine Package Manager to do it.

Now I am having problems because I cannot get the installation of OLPM to work...

I have tried to install the OnlinePackageManager using instructions on this page:
http://wiki.freepascal.org/Online_Package_Manager#Installation

I did select the available package onlinepackagemanager 1.0, then hit Install Selection and waited a while until it was done. Then I assume it was rebuilding the IDE, but nothing much happened when it was done. So I exited Lazarus and started it again, then went over to Package Install/Uninstall only to find that the "available" list is now missing OLPM but at the same time it is not part of the other list and it does not show up on the main Package menu.

In Package/Package Graph I can find the OLPM entry and it is marked with a green plus sign and when I click on it the info below shows this:

Filename:
C:\programs\lazarus_1.8.4-32\components\onlinepackagemanager\onlinepackagemanager.lpk State: Install on next start
Description: Online package manger

I have exited and restarted Lazarus several times already but it does not change a thing. No sign of OLPM.

What can I do to actually register OLPM with my Lazarus?

On previous installations this has "just worked" but not now....

Bo Berglund Developer in Sweden

Reply by email

Bo Berglund
to Bo Berglund
Bo Berglund wrote 14 lines
In Package/Package Graph I can find the OLPM entry and it is marked with a green plus sign and when I click on it the info below shows this: Filename: C:\programs\lazarus_1.8.4-32\components\onlinepackagemanager\onlinepackagemanager.lpk State: Install on next start Description: Online package manger I have exited and restarted Lazarus several times already but it does not change a thing. No sign of OLPM. What can I do to actually register OLPM with my Lazarus?

It seems like the problem was another package I had installed before but which dependent files could no longer be found. So I uninstalled that package first then reinstalled onlinepackagemanager and after some more cycles Indy10 has been installed. :)

Bo Berglund Developer in Sweden

Reply by email

Bo Berglund
to Bo Berglund: I have a console program for Windows, which was developed using Delphi2007 and Indy10.…
Bo Berglund wrote
I have a console program for Windows, which was developed using Delphi2007 and Indy10.

Now trying to compile the old Delphi sources in FPC/Lazarus and it stops in a common file on this type of construct:

  {$IF CompilerVersion >= 26} {Delphi XE5..}
    Fmt := TFormatSettings.Create;
  {$IFEND}

The error message is:
IniFileFuncs.pas(55,7) Error: Incompatible types: got "AnsiString" expected "Int64"
IniFileFuncs.pas(55,7) Error: Compile time expression: Wanted Boolean but got <erroneous type> at IF or ELSEIF

I guess this might be a FPC difference to Delphi... How can I make FPC understand that this is a conditional it shall just ignore?

Bo Berglund Developer in Sweden

Reply by email

Ralf Quint
to Bo Berglund
Bo Berglund wrote
I guess this might be a FPC difference to Delphi... How can I make FPC understand that this is a conditional it shall just ignore?

By first checking if you are compiling in FreePascal in the first place?

{$IFNDEF FPC}
   {$IF CompilerVersion >= 26} {Delphi XE5..}
         Fmt := TFormatSettings.Create;
   {$IFEND}
{$IFEND}

---
This email has been checked for viruses by Avast antivirus software. https://www.avast.com/antivirus

Reply by email

Bo Berglund
to Bo Berglund: I have a console program for Windows, which was developed using Delphi2007 and Indy10.…
Bo Berglund wrote 6 lines
I have a console program for Windows, which was developed using Delphi2007 and Indy10. Now I need to port this to Linux (Ubuntu Server 16.04-3 LTS on Intel i386 CPu). I have installed Lazarus 1.8.4-32 using the download from the official Lazarus site: lazarus-1.8.4-fpc-3.0.4-win32.exe

I have now succeeded in porting the code to Lazarus/FPC and it builds OK. A Windows32 exe file is produced.

So now to crosscompile for Linux:

When reading the wiki page
http://wiki.lazarus.freepascal.org/Cross_compiling#From_Windows_to_Linux I understand that the IDE is ready to build for Linux out of the box provided it is the same CPU family on the target.
So I changed the target from Default to Linux in
ProjectOptions/CompilerOptions/ConfigAndTarget/TargetOS

But when I try to build it does not work, instead I get the following error:

Compile package FCL 1.0.1: Exit code 1, Errors: 1
Fatal: Cannot find system used by fcllaz of package FCL.

I have no idea what this means, seems to have to do with Lazarus itself?
What to do next?

Bo Berglund Developer in Sweden

Reply by email

Bo Berglund
to Bo Berglund
Bo Berglund wrote 13 lines
When reading the wiki page http://wiki.lazarus.freepascal.org/Cross_compiling#From_Windows_to_Linux I understand that the IDE is ready to build for Linux out of the box provided it is the same CPU family on the target. So I changed the target from Default to Linux in ProjectOptions/CompilerOptions/ConfigAndTarget/TargetOS But when I try to build it does not work, instead I get the following error: Compile package FCL 1.0.1: Exit code 1, Errors: 1 Fatal: Cannot find system used by fcllaz of package FCL.

Is the wiki page falsely claiming that all you have to do to compile for Linux is to set the target to Linux? They say that the compiler is ready for all targets using the same CPU...

I have looked in my installation directory of Lazarus 1.8.4 which was installed from the binary installer. There is only a single system.ppu there and it is in this dir:
C:\Programs\lazarus_1.8.4-32\fpc\3.0.4\units\i386-win32\rtl Should there not be subdirectories for Linux too?
Or how are you supposed to get these?

Bo Berglund Developer in Sweden

Reply by email

Mattias Gaertner
to Bo Berglund: On Mon, 22 Oct 2018 21:09:56 +0200, Bo Berglund via Lazarus I have now succeeded in…

Did you install the binutils?
Did you crossbuild the linux fpc files?

I understand that the IDE is ready to build for Linux out of the box provided it is the same CPU family on the target.

fpc calls for example ppcx64, which can cross compile to other OS for all x86_64 targets. But you need the cross compiled ppu and o files for this target, here linux. And for Linux you need the binutils as well. See the wiki.

So I changed the target from Default to Linux in ProjectOptions/CompilerOptions/ConfigAndTarget/TargetOS

That only works after installing the cross compiled fpc files. After changing the target OS, when you click Ok of the Project Options, you should have seen an Error dialog "Compiler C:\lazarus\....exe does not support target x86_64-linux".

Mattias

Reply by email