Recent

Author Topic: Installing Lazarus on WSL2?  (Read 3839 times)

Wysardry

  • Jr. Member
  • **
  • Posts: 70
Installing Lazarus on WSL2?
« on: September 13, 2023, 01:38:33 am »
I recently installed WSL2 (Debian) on my Windows 10 laptop and would like to install both Lazarus and FreePascal on it, but need some help on how to go about it.

For one thing, I'm confused about the difference between the "lazarus" and "lazarus-ide" packages, and whether the "fpc" package is automatically included with either of them.

Can anyone offer any advice on the easiest way to go about this? I don't need the most recent version, as I will be using it to compile the trunk code (after I've downloaded it).

PierceNg

  • Sr. Member
  • ****
  • Posts: 398
    • SamadhiWeb
Re: Installing Lazarus on WSL2?
« Reply #1 on: September 13, 2023, 03:54:21 am »
WSL2 is the Linux kernel running on / integrated into the Windows kernel. Running a WSL2 Linux distro is (conceptually) running Linux in a virtual machine on Windows.

In WSL2, GUI apps like Lazarus IDE and the Lazarus apps you build, whether Lazarus-GTK or Lazarus-Qt, run on X11. This means they need to connect to an X11 display server running on the Windows host. Windows 11 (even the lowly Home edition) comes with a built-in X11 server. For Windows 10, you need 3rd party software. The popular one is VcXsrv. I myself use Cygwin/X because I already use Cygwin.

Apparently WSL2 on Windows 11 also supports Wayland.

See also: https://learn.microsoft.com/en-us/windows/wsl/tutorials/gui-apps

As for FPC, they are command line tools, so just install from the .deb files.

Wysardry

  • Jr. Member
  • **
  • Posts: 70
Re: Installing Lazarus on WSL2?
« Reply #2 on: September 13, 2023, 08:16:18 am »
I'm using a Windows 10 build greater than 19044 so it should be able to run GUI apps via WSL2, according to the Microsoft page you linked to.

I was able to install (and run) X11 apps and GIMP without problems.

Leledumbo

  • Hero Member
  • *****
  • Posts: 8783
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: Installing Lazarus on WSL2?
« Reply #3 on: September 13, 2023, 08:36:29 am »
For one thing, I'm confused about the difference between the "lazarus" and "lazarus-ide" packages, and whether the "fpc" package is automatically included with either of them.
Sounds like you're new to Linux especially Debian (derivatives) package management?
Here's a quick n dirty explanation:
lazarus is a dependency package, also called metapackage, acting as a disguise that always depends on whatever latest version is available in the repository. You can see in the "depends" section, that it currently depends on lazarus-2.2 package. So if you install this now, it will install lazarus-2.2 package as well. Some time later in the future, if say lazarus-2.4 comes out and becomes the latest, you don't have to manually install it, as it will be automatically installed due to this dependency.
lazarus-ide is another metapackage that also depends on the latest lazarus-ide, but it also provides selection of either lazarus-ide-gtk2-2.2 or lazarus-ide-qt5-2.2.
As of Debian customs, packages should be splitted according to its category. So other than the above two, lazarus has a bunch of other packages as well.
fpc is similar, with each package (in fpc sense) is a Debian package on its own. So, to answer the second question: no, fpc is not included per se, but it may well be a dependency.

PierceNg

  • Sr. Member
  • ****
  • Posts: 398
    • SamadhiWeb
Re: Installing Lazarus on WSL2?
« Reply #4 on: September 13, 2023, 02:22:42 pm »
I'm using a Windows 10 build greater than 19044 so it should be able to run GUI apps via WSL2, according to the Microsoft page you linked to.

I was able to install (and run) X11 apps and GIMP without problems.

Ah, nice, MS has incorporated built-in X server into latest Windows 10.

Here's one way to get FPC and Lazarus. I'm running Ubuntu 22.04 on WSL2. I have these .deb files downloaded previously:
  • fpc-laz_3.2.2-210709_amd64.deb
  • fpc-src_3.2.2-210709_amd64.deb

In WSL2 Ubuntu:
Code: Text  [Select][+][-]
  1. $ sudo dpkg -i fpc-laz_3.2.2-210709_amd64.deb
  2. $ sudo dpkg -i fpc-src_3.2.2-210709_amd64.deb
  3. $ fpc -h

For Lazarus I prefer to build from source:
Code: Text  [Select][+][-]
  1. $ sudo apt install libgtk2.0-dev
  2. $ echo Set up clean PATH without reference to /mnt/c, /mnt/d, etc which are the Windows C, D, ... drives
  3. $ git clone https://gitlab.com/freepascal.org/lazarus/lazarus
  4. $ cd lazarus
  5. $ make clean bigide
  6. $ ./startlazarus

Important: Set up clean PATH. Some notable bits before I did that:
  • I also have Windows distribution of Lazarus installed in C:\pkg\lazarus. "make clean" ran /mnt/c/pkg/lazarus/.../rm.exe -rf ...
  • rm.exe was slow in WSL2.
  • The make run was slow too, compared to when the machine runs Linux. (My machine dual boots.)
  • First run of make failed, because it tried to install the compiled units to /mnt/c/pkg/lazarus/fpc/3.2.2/... and got permission denied.
With a clean PATH, the make run went much faster.

Edit: First thing I do booting up the Lazarus IDE is to install the anchordockingdsgn package. Well, on WSL2 using Windows 10's built-in X server, the "install/uninstall packages" dialog box comes up, but I can't click on it! I also can't cycle to it using alt-tab. Pressing esc makes the dialog box go away though.

Hmm, doesn't look usable like this...
« Last Edit: September 13, 2023, 02:31:29 pm by PierceNg »

Wysardry

  • Jr. Member
  • **
  • Posts: 70
Re: Installing Lazarus on WSL2?
« Reply #5 on: September 13, 2023, 09:24:27 pm »
I have only been using Debian for a couple of months or so on an older laptop and haven't installed much beyond markdown, code and text editors.

I have used both the Synaptic GUI package manager and the command line, but only by following instructions.

WSL2 seems a little harder to use so far, as it doesn't have a desktop environment. I have read that you can add one, but I'm not sure how easy that would be or if it would help.

It also wasn't made clear in the Microsoft articles that I should use the WSL shortcut not the Debian one, as the latter is set to en_US instead of en_GB.

Am I right in thinking that if you install anything from .deb files you have to update manually?

PascalDragon

  • Hero Member
  • *****
  • Posts: 5811
  • Compiler Developer
Re: Installing Lazarus on WSL2?
« Reply #6 on: September 13, 2023, 10:53:07 pm »
I'm using a Windows 10 build greater than 19044 so it should be able to run GUI apps via WSL2, according to the Microsoft page you linked to.

I was able to install (and run) X11 apps and GIMP without problems.

Ah, nice, MS has incorporated built-in X server into latest Windows 10.

No. They incorporated a way for Wayland applications to display using rootless remote desktop and X11 applications simply work through XWayland running on WSL2 (as can be seen here).

PierceNg

  • Sr. Member
  • ****
  • Posts: 398
    • SamadhiWeb
Re: Installing Lazarus on WSL2?
« Reply #7 on: September 14, 2023, 03:49:19 am »
No. They incorporated a way for Wayland applications to display using rootless remote desktop and X11 applications simply work through XWayland running on WSL2 (as can be seen here).

Thanks for the link, very informative.

Since there is no direct X11 'over the wire' between WSLg and the Windows host, I started Cygwin/X on Windows and tried again. After setting DISPLAY and copying over Cygwin/X's .Xauthority file from Windows to Linux, X11 programs like gvim and Lazarus failed to connect to the X display server. Probably measures to protect the X server against network attacks. Or maybe I need to muck around with Windows firewall rules.

Anyways,, I started a 'local' (meaning on Windows Cygwin/X) xterm, ssh from it to WSL2 Ubuntu with X11 forwarding, then run 'startlazarus'. This time, the 'install / uninstall package' dialog box was usable, and I could select anchordockingdsgn and click 'rebuild IDE'.

BUT! When Lazarus restarted, it failed to paint its window properly, got stuck in partial full screen, was not responsive to mouse, and haphazardly responded to key presses. The xterm that started the app showed several lines "Gtk-critical: IA_gtk_window_set_keep_above: assertion GTK_IS_WINDOW (window) failed"

WSL2 seems a little harder to use so far, as it doesn't have a desktop environment. I have read that you can add one, but I'm not sure how easy that would be or if it would help.


Depends on how you use. When I tried it few months back, the full desktop X environment ran full screen, with its own login screen, just like running Linux-in-a-VM in full screen mode. Needed to press a hot key to escape from the X desktop to get back to Windows. Not for me. I prefer to be able to alt-tab through both Windows and X windows.   

But, given what I wrote on failing to run Lazarus in integrated windows mode, maybe you can try the full X desktop mode.

Am I right in thinking that if you install anything from .deb files you have to update manually?


Yes. You mentioned in your earlier post that you plan to build your own from source. Installing from the .deb files gives you the FPC for bootstrapping. Once you have built your own versions, you could uninstall the .deb version.

Wysardry

  • Jr. Member
  • **
  • Posts: 70
Re: Installing Lazarus on WSL2?
« Reply #8 on: September 15, 2023, 01:16:08 am »
Edit: First thing I do booting up the Lazarus IDE is to install the anchordockingdsgn package. Well, on WSL2 using Windows 10's built-in X server, the "install/uninstall packages" dialog box comes up, but I can't click on it! I also can't cycle to it using alt-tab. Pressing esc makes the dialog box go away though.

Hmm, doesn't look usable like this...
I installed everything (FPC, FPC source and Lazarus) from .deb files and had the same problem. The FP IDE seems to run okay, but I'm not sure that's any easier to live with.

It seems it's possible to use VSCode with WSL and there's a FreePascal Toolkit extension available.

Using Lazarus in native Windows with MSYS2 for the Git tools etc. or fpcupdeluxe would likely be a simpler setup though.

PierceNg

  • Sr. Member
  • ****
  • Posts: 398
    • SamadhiWeb
Re: Installing Lazarus on WSL2?
« Reply #9 on: March 15, 2024, 01:33:26 pm »
Edit: First thing I do booting up the Lazarus IDE is to install the anchordockingdsgn package. Well, on WSL2 using Windows 10's built-in X server, the "install/uninstall packages" dialog box comes up, but I can't click on it! I also can't cycle to it using alt-tab. Pressing esc makes the dialog box go away though.

Hmm, doesn't look usable like this...

I just rebuilt Lazarus IDE with Qt5 widget set on WSL2 (this time on a Windows 11 machine):

Code: Text  [Select][+][-]
  1. % make clean bigide LCL_PLATFORM=qt5

With Qt5, after starting the IDE for the first time, installing the anchordockingdsgn package worked as expected: I could navigate the dialog boxes to add the package, and upon rebuilding/restarting the IDE came up docked. More usable than with the default GTK2.

 

TinyPortal © 2005-2018