Coming to wsl2 for the first time having previously used fpc a little on macOS and Linux, I stated with a small project that I know builds. However, on Linux (Ubuntu) in wsl2 it fails ...
$ fppcame
$ make
Makefile:135: *** Compiler .exe not found. Stop.
I wondered if it need the path setting so I tried the...
$ export FPCDIR=/usr/lib/x86_64-linux-gnu/fpc/3.0.4
$ fppcame
$ make
Makefile:135: *** Compiler /usr/bin/fpc.exe not found. Stop.
Just to check I did this..
$ $ which -a fpc
/usr/bin/fpc
/bin/fpc
$ which -a fpc.exe
[nothing]
Why is it looking for fpc.exe when running in Linux (wsl2)?
Looking at the Makefile generated by fpcmake I see it seem to be checking for pwd.exe, presumably to check if it's in a Windows system and then presumes if pwd,exe exist then fpc is a fpc.exe (mostly guesswork I found the Makefile rather difficult to understand)
Yes, pwd.exe is on my path. Seems the windows path is automatically prepended to the Linux path (which is useful as I can thus access Windows applications such as explorer.exe)
$ which pwd.exe
/mnt/c/LatticeMico8/cygwin/bin/pwd.exe
That needs to be in my Windows path as I use LatticeMico8 for development
To confirm my guesswork I manually edited the Makefile and changed pwd.exe to xxpwd.exe so it would not be found, now I get..
$ make
/usr/bin/fpc -Fu/usr/lib/x86_64-linux-gnu/fpc/3.0.4/units/x86_64-linux/rtl -FE. -FUunits/x86_64-linux -Cg -dx86_64 magic.pas Free Pascal Compiler version 3.0.4+dfsg-23 [2019/11/25] for x86_64
Copyright (c) 1993-2017 by Florian Klaempfl and others
Target OS: Linux for x86-64
Compiling magic.pas
Linking ./magic
/usr/bin/ld.bfd: warning: ./link.res contains output sections; did you forget -T?
30 lines compiled, 0.2 sec
So, the question is. What did I do wrong? I assume manually editing the Makefile is not the the correct solution, especially for beginners.
I found one forum post from five years ago that seemed to apply, titled "wsl: convincing FPC that it is on Linux" (
https://forum.lazarus.freepascal.org/index.php/topic,42267.msg294817.html#msg294817), but honestly I don't understand what the solution was (or much of what was being discussed). I'm also assuming in five years things will have move on, or is using fpc on wsl/wsl2 really unusual?
Version info...
$ fpc -v
Free Pascal Compiler version 3.0.4+dfsg-23 [2019/11/25] for x86_64
...
$ fpcmake -V
FPCMake Version 2.0.0 [2017-02-13 rev 35434]
$ uname -a
Linux Duc101 5.15.90.1-microsoft-standard-WSL2 #1 SMP Fri Jan 27 02:56:13 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux