The Windows Subsystem for Linux is the quickest way to get started with Linux deployment from Delphi (WSL). WSL2 now includes a full Linux kernel in Windows 10 Version 2004 (Build 19041), so debugging and everything works as expected.
- Install WSL2 (You can verify your build number via the System Information applet, but Build 19041 has been available for a while now.)
- Control Panel
- Programs
- Turn Windows features on or off
- Windows Subsystem for Linux
- Reboot
- Install Ubuntu via the Microsoft Store – Ubuntu without version # is the current LTS version and will update in the future. There are other distributions (Kali, Pegwin, Alpine WSL, etc.), but they are all a little different.
- Launch Ubuntu – Via the Start Menu or from a PowerShell/Terminal/CLI window with the
WSL
orUbuntu
commands. If you have more than one Linux installed then WSL launches the default one. The first time you launch it be aware it will take a few minutes, and then prompt you for new Linux credentials. - Run SetupUbuntu4Delphi21.sh – I made a script on gist that does all the setup for Ubuntu to get it ready to target from Delphi. You can use
wget
to download it or you can type the commands manually. It creates a script file called pa21.sh in your home folder to quickly launch PAServer. You can modify it to pass default configuration settings.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
#!/bin/bash echo Updating the local package directory sudo apt update echo Upgrade any outdated pacakges sudo apt full-upgrade -y echo Intall new packages necessary for Delphi sudo apt install joe wget p7zip-full curl openssh-server build-essential zlib1g-dev libcurl4-gnutls-dev libncurses5 xorg libgl1-mesa-dev libosmesa-dev libgtk-3-bin -y echo Clean-up unused packages sudo apt autoremove -y cd ~ echo Downloading LinuxPAServer for Sydney 10.4 (21.0) Update 1 wget https://altd.embarcadero.com/releases/studio/21.0/1/PAServer/LinuxPAServer21.0.tar.gz echo Setting up directories to extract PA Server into mkdir PAServer mkdir PAServer/21.0 tar xvf LinuxPAServer21.0.tar.gz -C PAServer/21.0 --strip-components=1 rm LinuxPAServer21.0.tar.gz echo \#\!\/bin\/bash >pa21.sh echo ~/PAServer/21.0/paserver >>pa21.sh chmod +x pa21.sh echo ----------------------------------- echo To launch PAServer type \~/pa21.sh echo ----------------------------------- ~/pa21.sh |
- Install FMXLinux from GetIt
- Run the
broadwayd
server – You should already havepaserverit running (the
script above launched), so you will probably want a new Ubuntu terminal window where you can launchbroadwayd
. I like using the new Windows Terminal since it makes it easy to open multiple tabs, and WSL integrates nicely with it.
- Import Linux SDK in Delphi IDE – Tools > Options > Deployment > SDK Manager – The IP address for the PAServer instance is localhost /
127.0.0.1
, so keep in mind you are sharing ports between the WSL instance and your host Windows 10 OS.
- Now is just a matter of running most any FireMonky project and connecting to
localhost:8080
from your browser.
One thing to keep in mind is that there is one instance of the app running on the server for each client, and each has its own port number. There are ways to manage this on the server with a little effort, but that is a blog post for another day.
Interested in building Linux applications with FireMonkey? Try the Cross-Platform Development Framework, which can help you create & design apps in Delphi or C++ environments.
Design. Code. Compile. Deploy.
Start Free Trial Upgrade Today
Free Delphi Community Edition Free C++Builder Community Edition
Nice Video, Looking foward for the video to show how to have diferent users using the same port