I am trying to compile/port on Linux a project which was originally written in Delphi on Windows. I have zero experience with Delphi on Windows and I have only very limited experience with Pascal.
I am running in Ubuntu 22.04.3 LTS and I have installed system-provided Freepascal and Lazarus with sudo apt install fp-units-* lcl-* lazarus lcl fpc-* (I've reached this list by trials and errors which helped me making progress towards trivial errors).
When I try to compile the top level program file, it fails as follows:
$ fpc myprogr.dpr Free Pascal Compiler version 3.2.2+dfsg-9ubuntu1 [2022/04/11] for x86_64 Copyright (c) 1993-2021 by Florian Klaempfl and others Target OS: Linux for x86-64 Compiling myprogr.dpr myprogr.dpr(4,3) Fatal: Can't find unit Forms used by myprogr Fatal: Compilation aborted Error: /usr/bin/ppcx64 returned an error exitcode
which is weird because the stuff is there:
$ dpkg -S /usr/lib/lazarus/2.2.0/lcl/forms.pp lazarus-src-2.2: /usr/lib/lazarus/2.2.0/lcl/forms.pp $ ls -l /usr/lib/lazarus/2.2.0/lcl/forms.pp -rw-r--r-- 1 root root 92597 Jan 2 2022 /usr/lib/lazarus/2.2.0/lcl/forms.pp
And that leads me to believe that something is wrong with the packages I am utilizing, but anyway I manually add the path, and the failure becomes:
$ fpc -Fu/usr/lib/lazarus/2.2.0/lcl/ myprogr.dpr Free Pascal Compiler version 3.2.2+dfsg-9ubuntu1 [2022/04/11] for x86_64 Copyright (c) 1993-2021 by Florian Klaempfl and others Target OS: Linux for x86-64 Compiling myprogr.dpr Compiling /usr/lib/lazarus/2.2.0/lcl/forms.pp forms.pp(24,2) Fatal: Cannot open include file "lcl_defines.inc" Fatal: Compilation aborted Error: /usr/bin/ppcx64 returned an error exitcode
Weird again as before because:
$ dpkg -S lcl_defines.inc lazarus-src-2.2: /usr/lib/lazarus/2.2.0/lcl/include/lcl_defines.inc $ ls -l /usr/lib/lazarus/2.2.0/lcl/include/lcl_defines.inc -rw-r--r-- 1 root root 325 Jul 11 2020 /usr/lib/lazarus/2.2.0/lcl/include/lcl_defines.inc
which I can make again progress with:
$ fpc -Fu/usr/lib/lazarus/2.2.0/lcl/ -I/usr/lib/lazarus/2.2.0/lcl/include/ myprogr.dpr Free Pascal Compiler version 3.2.2+dfsg-9ubuntu1 [2022/04/11] for x86_64 Copyright (c) 1993-2021 by Florian Klaempfl and others Target OS: Linux for x86-64 Compiling myprogr.dpr Compiling /usr/lib/lazarus/2.2.0/lcl/forms.pp Compiling /usr/lib/lazarus/2.2.0/lcl/lclstrconsts.pas Writing Resource String Table file: lclstrconsts.rsj lclstrconsts.pas(481) Error: Writing Resource String Table file: > /usr/lib/lazarus/2.2.0/lcl/lclstrconsts.rsj lclstrconsts.pas(481) Fatal: There were 1 errors compiling module, stopping Fatal: Compilation aborted Error: /usr/bin/ppcx64 returned an error exitcode
And that continues the weirdness because:
$ dpkg -S lclstrconsts.rsj lcl-units-2.2: /usr/lib/lazarus/2.2.0/lcl/units/x86_64-linux/lclstrconsts.rsj $ ls -l /usr/lib/lazarus/2.2.0/lcl/units/x86_64-linux/lclstrconsts.rsj -rw-r--r-- 1 root root 77783 Apr 11 2022 /usr/lib/lazarus/2.2.0/lcl/units/x86_64-linux/lclstrconsts.rsj
on top of which why is the compiler trying to write in global location rather than locally, but I digress.
Of course I looked at the Freepascal, Lazarus and a bit at the Ubuntu/Debian documentation (as well as generic web search), and nothing seemed to indicate this sort of problems...
I can jump into the rabbit hole and continue to reverse engineer all of this which potentially might even succeed compiling the project as I need, but instead I'd rather ask: am I doing something obviously wrong? Is the Freepascal and Lazarus projects in my distro broken (which means, should I rather compile them from source)?
As @HeartWare as noticed in a comment, the root cause of the impossibility to move forward is that the code uses Windows, Forms and many other Microsoft-specific units which do not have a Linux equivalent. This is unfortunate, but the most unfortunate aspect is that it's not clear at all from reading the documentation as a newbie, where it sounds like they have ported all units for all OSes.
But the most time consuming issue is that to compile the code I need a whopping
This is both with the OS-provided and with the freepascal.org-provided (binary) installation. Being familiar with several other programming languages, this sounds really counterintuitive, in that the stuff in
/usris always automatically included by the compilers/interpreters because so specified in some global configuration, e.g./usr/include/in C.I still don't understand if that's the way it is for FreePascal or if it's something wrong with the binary installs for my OS which lack a global configuration setting.