Recent

Author Topic: Using in wsl2 (Windows Subsystem for Linux v2)  (Read 1253 times)

sjb

  • Newbie
  • Posts: 2
Using in wsl2 (Windows Subsystem for Linux v2)
« on: September 04, 2023, 11:41:02 am »
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 ...
Code: Pascal  [Select][+][-]
  1.  $ fppcame
  2. $ make
  3. Makefile:135: *** Compiler .exe not found.  Stop.
  4.  

I wondered if it need the path setting so I tried the...
Code: Pascal  [Select][+][-]
  1. $ export FPCDIR=/usr/lib/x86_64-linux-gnu/fpc/3.0.4
  2. $ fppcame
  3. $ make
  4. Makefile:135: *** Compiler /usr/bin/fpc.exe not found.  Stop.
  5.  

Just to check I did this..
Code: Pascal  [Select][+][-]
  1. $ $ which -a fpc
  2. /usr/bin/fpc
  3. /bin/fpc
  4. $ which -a fpc.exe
  5. [nothing]
  6.  

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)
Code: Pascal  [Select][+][-]
  1. $ which pwd.exe
  2. /mnt/c/LatticeMico8/cygwin/bin/pwd.exe
  3.  
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..
Code: Pascal  [Select][+][-]
  1.  $ make
  2.  /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
  3. Copyright (c) 1993-2017 by Florian Klaempfl and others
  4. Target OS: Linux for x86-64
  5. Compiling magic.pas
  6. Linking ./magic
  7. /usr/bin/ld.bfd: warning: ./link.res contains output sections; did you forget -T?
  8. 30 lines compiled, 0.2 sec
  9.  

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...
Code: Pascal  [Select][+][-]
  1. $ fpc -v
  2. Free Pascal Compiler version 3.0.4+dfsg-23 [2019/11/25] for x86_64
  3. ...
  4. $ fpcmake -V
  5. FPCMake Version 2.0.0 [2017-02-13 rev 35434]
  6. $ uname -a
  7. 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
  8.  




marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11944
  • FPC developer.
Re: Using in wsl2 (Windows Subsystem for Linux v2)
« Reply #1 on: September 04, 2023, 04:36:50 pm »
From what I remembered, I simply had a simple shellscript that inited the PATH to some sane values, so that pwd.exe wasn't in the $PATH

sjb

  • Newbie
  • Posts: 2
Re: Using in wsl2 (Windows Subsystem for Linux v2)
« Reply #2 on: September 07, 2023, 08:03:03 pm »
From what I remembered, I simply had a simple shellscript that inited the PATH to some sane values, so that pwd.exe wasn't in the $PATH
Thank you.  I was worried I was missing something.

Maybe I'm overthinking this. I've seen a suggestion that Makefile.fpc is not intended for that rank and file users and I should just do...
Code: Pascal  [Select][+][-]
  1. fpc magic
  2.  
Which does work, but there no easy way to clean the directory. So maybe I should write my own Makefile.  To be honest, this is the most confusing part of doing anymore than a trivial example with fpc.  But maybe my brain is too engrained with how I would build a c program.  %)

Sorry for the delayed thank you - this little heatwave here in the UK has kept away from doing the fun stuff



PascalDragon

  • Hero Member
  • *****
  • Posts: 5759
  • Compiler Developer
Re: Using in wsl2 (Windows Subsystem for Linux v2)
« Reply #3 on: September 07, 2023, 09:32:30 pm »
From what I remembered, I simply had a simple shellscript that inited the PATH to some sane values, so that pwd.exe wasn't in the $PATH

Indeed. When I do builds of FPC in WSL I first do a echo $PATH and then a export PATH=... with all the paths that are not located on Windows.

 

TinyPortal © 2005-2018