getting fpc cross-compiling on Fedora Linux. lazarus / 1-Linux ---------------------------------------------------------------------- lazer · 2022-10-13 08:31 Hi, I'm using Fedora 35 and have installed Lazarus ( and hence fpc ) from distro.  Native building seems fine. Now I need to compile for a win64 win32 targets.  Years ago I did this and it all worked out of the box, I was impressed. Now it's become a "challenge". fpc files are installed in: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i /usr/lib64/fpc/3.2.2/units/x86_64-linux/rtlthe source is in : Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i /usr/share/fpcsrc/packagesCode: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i ls -d  /usr/share/fpcsrc/packages/rtl*/usr/share/fpcsrc/packages/rtl-console  /usr/share/fpcsrc/packages/rtl-generics  /usr/share/fpcsrc/packages/rtl-unicode/usr/share/fpcsrc/packages/rtl- extra    /usr/share/fpcsrc/packages/rtl-objpas This seems pretty standard but there is also : Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i /usr/share/fpcsrc/rtl https://wiki.freepascal.org/Cross_compiling_for_Windows_under_Linux It looks like I need to build the cross compiler since this is not provided in the distro pkg. Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i export FPCVER="3.2.2"cd /usr/share/fpcsrc/"$FPCVER"/make clean all OS_TARGET=win64 CPU_TARGET=x86_64make clean all OS_TARGET=win32 CPU_TARGET=i386 There is a deviation here since $FPCVER seems to be "package" in this installation. In anycase I set that value and cd to that directory. Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i make clean all OS_TARGET=win64 CPU_TARGET=x86_64... Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i make[1]: Leaving directory '/usr/share/fpcsrc/packages/fpmkunit'./fpmake clean --localunitdir=.. --os=win64 --cpu=x86_64 -o -Twin64 -o -XPx86_64-win64- -o -Xr -o -dx86_64 --compiler=/usr/bin/ppcx64 -bu -scp./fpmake compile --localunitdir=.. --os=win64 --cpu=x86_64 -o -Twin64 -o -XPx86_64-win64- -o -Xr -o -dx86_64 --compiler=/usr/bin/ppcx64 -bu -scpThe installer encountered the following error:Could not find unit directory for dependency package "rtl" required for package "bzip2"make: *** [Makefile:1721: all] Error 1   I'm suspecting that the slightly non-standard tree is the cause. Maybe I need to symlink the rtl dir , can anyone advise ? TIA. ---------------------------------------------------------------------- dbannon · 2022-10-13 09:29 Hmm, the instructions you are following were written assuming a FPC installed as described. Sadly, distro packages like to move things around. You could try some symlinks in the appropriate place I guess but as I don't use Fedora, no guarantees. I suspect you might need to follow whats happening a bit more closely, there is no magic in the recipe provided, it just uses the supplied Makefile with a suitable parameter.  You must however end up with things such as RTL in a place defined in the fpc.cfg file. In theory, anywhere you like but a lot easier if you follow conventions. The fpc.cfg typically has a $VER in the various paths but I see no intrinsic reason why it could not be "package" but if you could replicate the original structure, again, life would be easier. Davo ---------------------------------------------------------------------- Leledumbo · 2022-10-13 09:39 I suggest uninstalling distro packages and use distro agnostic tar archive instead. The situation is similar with Debian derivatives, no idea why the package maintainer does that (changing the directory hierarchy around). ---------------------------------------------------------------------- dbannon · 2022-10-13 10:13 in fact Leledumbo, the wiki howto used the SourceForge FPC, but a deb not an RPM package. Like you, I prefer a Tar install of FPC but wrote the howto based on the SourceForge package because more new user prefer that model. Its easily adapted to the Tar model and that would be better as it would be far more uniform between distros ... On the other hand, its definitely not easily adapted easily to either the Debian produced deb, nor, I suspect the distro preferred RPM. Laser, in short, Leledumbo is sort of right, get the official FPC fpc and life will be easier still ! Davo ---------------------------------------------------------------------- lazer · 2022-10-13 14:56 Thanks for all the replies. I prefer to use distro pkgs where possible since the that is the point of a distro. If I install fpc by hand I then have to do Lazarus by hand to fiddle with distro config so that it knows I'm supposed to be in charge of that and ignores any deps. I have a small number pkgs which I run this way but I aim to keep it as small as is really necessary. I suspect there is trivial tweak here like defining something in fpc.cfg or making a sym link. ---------------------------------------------------------------------- PascalDragon · 2022-10-14 13:53 Quote from: lazer on October 13, 2022, 04:56:07 pmI prefer to use distro pkgs where possible since the that is the point of a distro. If I install fpc by hand I then have to do Lazarus by hand to fiddle with distro config so that it knows I'm supposed to be in charge of that and ignores any deps. Then at least don't use the sources as provided by the distro. Download the sources for FPC 3.2.2 and do your make crossall OS_TARGET=win32 CPU_TARGET=i386 followed by make crossinstall OS_TARGET=win32 CPU_TARGET=i386 INSTALL_PREFIX=/path/where/it/should/install (and similar for x86_64-win64) inside its top level directory. ---------------------------------------------------------------------- lazer · 2022-10-15 08:57 Thanks I have discovered that Fedora do not even include 386 fpc ( like they don't for any other packages ) . Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i Error: ppc386 can't be executed, error message: Failed to execute "ppc386", error code: 127 So I tried to build from github. All went well until I installed and discovered I got 3.3.1  Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i make[4]: Entering directory '/svn/FPCSource-main/packages'./fpmake install --localunitdir=.. --os=win32 --cpu=i386 -o -Twin32 -o -Pi386 -o -XPi386-win32- -o -Ur -o -Xs -o -O2 -o -n -o -di386 -o -dRELEASE --compiler=/svn/FPCSource-main/compiler/ppcross386 -bu -scp --prefix=/usr --baseinstalldir=/usr/lib/fpc/3.3.1 Let's see how far that gets. ---------------------------------------------------------------------- lazer · 2022-10-15 13:03 QuoteThe project uses target OS=win32 and CPU=x86_64. The system.ppu for this target was not found in the FPC binary directories. Make sure fpc is installed correctly for this target and the fpc.cfg contains the right directories. Clearly mixing versions is not going to work well. Where can I get official fpc source for version 3.2.2. ? Thx. ---------------------------------------------------------------------- lazer · 2022-10-15 13:33 https://gitlab.com/freepascal.org/fpc/source/- /archive/release_3_2_2/source-release_3_2_2.tar.bz2 OK I built 3.2.2. Native still compiles fine. If I which TARGET to Win32 or Win64  and click "Test"  , it fails to find all RTL units: QuoteError: RTL unit not found: sysutils.ppu If continue and try to compile , I get : QuoteThe project uses target OS=win32 and CPU=x86_64. The system.ppu for this target was not found in the FPC binary directories. Make sure fpc is installed correctly for this target and the fpc.cfg contains the right directories. QuoteFatal: Cannot find system used by fcllaz. Make sure all ppu files of a package are in its output directory. ppu in wrong directory=/usr/lib/fpc/3.2.2/units/x86_64-win64/rtl/system.ppu.. Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i grep Fu /etc/fpc.cfg-Fu/usr/lib64/fpc/$fpcversion/units/$fpctarget-Fu/usr/lib6 4/fpc/$fpcversion/units/$fpctarget/*- Fu/usr/lib64/fpc/$fpcversion/units/$fpctarget/rtl- Fu/usr/lib/fpc/$fpcversion/units/$fpctarget-Fu/usr/lib/fpc/$fpcversion /units/$fpctarget/*-Fu/usr/lib/fpc/$fpcversion/units/$fpctarget/rtl- Fu/usr/units/$fpctarget/$fpcsubarch-$fpcmemorymodel-Fu/usr/units/$fpct arget/$fpcsubarch-$fpcmemorymodel/*- Fu/usr/units/$fpctarget/$fpcsubarch-$fpcmemorymodel/rtl-Fu/usr/lib64/f pc/$fpcversion/units/$fpctarget/httpd13/- Fu/usr/lib/fpc/$fpcversion/units/$fpctarget/httpd13/- Fu/usr/lib64/fpc/$fpcversion/units/$fpctarget/httpd20/- Fu/usr/lib/fpc/$fpcversion/units/$fpctarget/httpd20/- Fu/usr/lib64/fpc/$fpcversion/units/$fpctarget/httpd22/- Fu/usr/lib/fpc/$fpcversion/units/$fpctarget/httpd22/- Fu~/.fppkg/lib/fpc/$fpcversion/units/$FPCTARGET/*  Full disclosure : Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i ls /usr/units/ls: cannot access '/usr/units/': No such file or directory  ~/.fppkg/lib/fpc/  does not exist either. ---------------------------------------------------------------------- lazer · 2022-10-15 14:57 It still can't find anything... even if it is there. Quotels -ail /usr/lib/fpc/3.2.2/units/x86_64-linux/rtl/system.ppu 1464493 -rw-r--r--. 1 root root 888064 Oct 15 16:09 /usr/lib/fpc/3.2.2/units/x86_64-linux/rtl/system.ppu ---------------------------------------------------------------------- Thaddy · 2022-10-15 15:03 Fedora is at release 37, not 35. You may not be able to install FPC from Fedora's repository. You are using an old distro, with an old FPC as a result. You may be able to bootstrap the sources to compile it yourself, but make sure the bootstrap compiler is at least up-to-date. (requires FPC 3.2.0) ---------------------------------------------------------------------- lazer · 2022-10-15 15:11 The distroF35 is still maintained.  If you read what I posted you will see it provides 3.2.2  so it is not "old". That is the "bootstrap" with which I just rebuilt 3.2.2 and 3.3.1 without any build issues. The problem is Lazarus can't find RTL files which are present in the standard place. I don't see what that has to do with fpc version. ---------------------------------------------------------------------- Thaddy · 2022-10-15 15:36 The bootstrap compiler is usually the current release minus 2. The fact that Lazarus - basically fpc itself can't find certain units is because the rtl is versioned. FPC needs the proper rtl, NOT old stuff. ---------------------------------------------------------------------- lazer · 2022-10-15 15:59 Quotednf info fpc-src Last metadata expiration check: 0:00:11 ago on Sat 15 Oct 2022 17:53:59 CEST. Installed Packages Name         : fpc-src Version      : 3.2.2 Release      : 3.fc35 Architecture : noarch Size         : 244 M Source       : fpc-3.2.2-3.fc35.src.rpm Repository   : @System From repo    : fedora Summary      : Free Pascal Compiler - sources URL          : http://www.freepascal.org/ License      : GPLv2+ and LGPLv2+ with exceptions Description  : The fpc-src package contains the sources of Free Pascal, for documentation or              : automatical-code generation purposes. I already stated that F35 supplies 3.2.2  , so trying to build and install 3.2.2 with 3.2.2   is  NOT OLD STUFF. Plus I also stated that went without a problem. The problem is that Lazarus is unable to configure using the new file locations. Even after adjusting fpc.cfg and pointing the start-up dlg to the correct location.    It can't see what is already there. Close all windows, if that does work reboot, if that doesn't work reinstall operating system.   LOL ---------------------------------------------------------------------- dbannon · 2022-10-16 09:48 Lazer, I really think it would be a lot easier if you stick with just one approach. We have established that the Fedora Repo does not support 32bit so, perhaps, dropping the Fedora one might be a good start. Now you are left with installing FPC by one of three ways - * Build it from source. * Install from a Tarball * Install from a RPM, Fedora's native package model. They are listed, incidentally, hardest from the top, easiest at the bottom.  I suggest the Tarball if you want to build cross compilers, it has everything you need and can be installed in userspace, making the process easier and safer. And its still reasonably hard and you seem to like that. Installing from the RPM is dead easy but a bit harder to build the cross compiler    The one issue you will encounter is that Fedora likes its libraries in different places and you may need to manually edit the config file accordingly. In most cases, you need to edit that config file, each platform has its own section, I suspect that the Fedora Repo version has the 32bit section removed. Makes sense, they don't do 32bit. Anyway, its pretty normal to edit the config file when building cross compilers, do not assume the defaults will always work because the various Linux Distributions like to put things in different places. Davo ---------------------------------------------------------------------- lazer · 2022-10-16 10:57 Many thanks for the help Dbannon. After about 3 days of effort I got it fixed. Having seen that Fedora don't even support cross compiling and make it impossible for i386, I gave up on my usual prefence of letting the distro handle this package and decided to go from project source for both fpc and lazarus. Using the distro's 3.2.2 I built 3.3.1 with cross for win32 on i386 and win64 on x64. make clean all OS_TARGET=win64 CPU_TARGET=x86_64 make clean all OS_TARGET=win32 CPU_TARGET=i386 As you point out the fpc.cfg needed editing because Fedora (logically) puts the x64 builds in /usr/lib64 . It seems with upstream all goes in /usr/lib . Having built lazarus, and running startlazarus, I was able to select  my 3.3.1 tree in the IDE setup dialogue. This time it found what it wanted and it all fired up. The was a grumble about multiple copies of some units files.  It seems lazarus provides these as well as the compiler. I renamed the lazarus units and notunits and it seems fine with that. I don't know whether that was the best choice. Now I would like to build for win32 on x64 which is what the actual target platform is. A lot of old hardware is x64 but the cheapo entry level windows "Home" gave you a 32 bit OS on 64bit h/w. Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i make clean all OS_TARGET=win32 CPU_TARGET=x86_64Makefile:235: *** The Makefile doesn't support target x86_64-win32, please run fpcmake first.  Stop.   Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i fpcmake -T x86_64-win32Processing Makefile.fpcError: No targets set  Can you advise on how that works? thanks. ---------------------------------------------------------------------- dbannon · 2022-10-17 00:00 Again, by having a distro supplied FPC install there as well as the SourceForge one, you are complicating things so, so unnecessarily. You must now ensure that you PATH points to the new compiler's location BEFORE it get to /usr/bin (or whereever Fedora puts it). Am I right in saying you are looking for x86_64-win32 ? I most certainly am not a windows expert but I suspect what you want is i386-win32.  If its win32 it assumes the i386 instruction set. All those instructions are available on x86_64 so it runs fine there. Saying win32 on x86_64 does not make sense IMHO. I build binaries of my app for Win32 i386 and win64 x86_64 and have never been asked for any any other combination. And, to my chagrin, I get more Windows downloads than Linux ! Anyway, other comments, probably not significant - You have not told us in which dir you are running it, maybe its in the Fedora supplied one and we have established that Fedora has removed the 32bit capability and, again guessing, probably the win32 capability. Anyway, the Makefile is a ripper !  Have a look through it and see if it mentions win32 - maybe compare that to the Makefile in the content you downloaded from SourceForge.  Mine does mention i386-win32 but most certainly not a 64bit version of that. Please read https://wiki.freepascal.org/Cross_compiling_for_Windows_under_Linux - the second paragraph is particularly significant. Davo ---------------------------------------------------------------------- lazer · 2022-10-17 06:32 Thanks, that's probably a fake installation I invented.  I have as little to do with winWorld as possible. An intentionally crippled win32 OS running on x64 hardware would probably refuse to have anything to do with x64 instructions. So what I was envisaging does not make sense. Before building from source, I removed distro fpc and lazarus, but then found there was no compiler to build with ( I had imagined the tarball would include binaries so that it was not dependent on unknown distro or other compilers ). I had to reinstall Fedora's fpc to build the upstream source code. Once I have done makeinstall and set up the symlinks , I checked bash finds the right version: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i fpc -vFree Pascal Compiler version 3.3.1 [2022/10/16] for x86_64Copyright (c) 1993-2022 by Florian Klaempfl and othersFatal: No source file name in command lineFatal: Compilation abortedError: /usr/bin/ppcx64 returned an error exitcode  Just to have a clear conscience, I've now removed the distro fpc and reasserted the cfg and symlinks it kindly removed on the way out. ---------------------------------------------------------------------- dbannon · 2022-10-17 07:18 Quote from: lazer on October 17, 2022, 08:32:14 amBefore building from source, I removed distro fpc and lazarus, but then found there was no compiler to build with ( I had imagined the tarball would include binaries so that it was not dependent on unknown distro or other compilers ). Both the rpm and the tarball includes the native compiles and all the other, related binaries. Not cross compilers but all native stuff is there. See https://wiki.freepascal.org/Installing_the_Free_Pascal_Comp iler#FPC_Tar_Balls there is a series of, perhaps, 15 lines that end with the "fpc -v" command demonstrating a clean install. Quote from: lazer on October 17, 2022, 08:32:14 amI had to reinstall Fedora's fpc to build the upstream source code. No you did not. Davo ---------------------------------------------------------------------- lazer · 2022-10-17 08:48 Thanks for the link. QuoteCompiling the FPC source     First install the release FPC from rpm/deb or tar balls as described above. That is what I was following. ---------------------------------------------------------------------- Thaddy · 2022-10-17 08:50 afaik fedora supports multi-arch but then you must install it. ---------------------------------------------------------------------- lazer · 2022-10-17 09:46 Yeah, thanks, I'm done with Fedora on this one. A distro is supposed to make life easier and take some of the load. When it makes life harder , I'm out.  Plus support and bug reporting is near non existent on Fedora. Though I have found it generally fairly reliable as long as you stay well behind the curve and let others find the bugs first.  That's why I'm still on F35. ---------------------------------------------------------------------- dbannon · 2022-10-17 10:36 Fedora is an alpha test platform for RedHat. But a bit unfair to blame them here. You started by insisting on sticking with distro FPC and now you are, apparently, insisting that the Official FPC tar balls don't have any binaries  Anyway, Ubuntu ?  With Ubuntu, you get the same release their commercial customers are using. They have dropped 32bit releases but still have 32bit libraries available in, at least, U2004, supported for some time yet. I cannot speak for U2204 but think its still OK. Debian still makes 32bit releases and has all the 32bit compatibility libraries available for 64bit. I made some comment about the demise of 32bit over there and was quite firmly taken to task. But, please note, Debian/Ubuntu Distro installs of FPC are not, IMHO, suitable for building cross compilers. Its still a case of installing FPC from the Tarball or RPM and building the cross compilers from there. I am unaware of any distro that ships FPC Crosscompilers from its repo. I build my releases, Linux (32, 64) debs, rpms etc, Windows (32, 64), RasPi, Pacman from a Ubuntu2004 Virtual Box VM. I guess I could strip out the private stuff and send it to you, its a sizable file .... Davo ---------------------------------------------------------------------- lazer · 2022-10-17 11:45 Quote Official FPC tar balls don't have any binaries  No I didn't. QuoteYou started by insisting on sticking with distro FPCI started saying I prefered to use distro pkg where possible . When I found it was impossible to build the i386 cross compiler I decided that was not a useful option. Changing ones opinion as a result of new information is often a good idea. QuoteI could strip out the private stuff and send it to you,Very kind, but I think I've got clean upto date installation with all cross stuff I need know.  Now to battle with the debugger ... Thanks for your help on this issue.