Have an amazing solution built in RAD Studio? Let us know. Looking for discounts? Visit our Special Offers page!
DelphiNews

Deploying FireMonkey to HTML5 with FMXLinux on WSL2

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.

 

  1. Install WSL2 (You can verify your build number via the System Information applet, but Build 19041 has been available for a while now.)
    1. Control Panel
    2. Programs
    3. Turn Windows features on or off
    4. Windows Subsystem for Linux
    5. Reboot

 

Installing WSL2 on Windows 10

 

  1. 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.

 

 

  1. Launch Ubuntu – Via the Start Menu or from a PowerShell/Terminal/CLI window with the WSLor Ubuntu 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.
  2. 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. Install FMXLinux from GetIt

 

 

  1. Run the broadwayd server – You should already have paserverit ​running​ (thescript above launched), so you will probably want a new Ubuntu terminal window where you can launch broadwayd. I like using the new Windows Terminal since it makes it easy to open multiple tabs, and WSL integrates nicely with it.

 

 

  1. 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.

 

 

  1. 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.

See What's New in 12.2 Athens See What's New in 12.2 Athens Dev Days of Summer 2-24

Reduce development time and get to market faster with RAD Studio, Delphi, or C++Builder.
Design. Code. Compile. Deploy.
Start Free Trial   Upgrade Today

   Free Delphi Community Edition   Free C++Builder Community Edition

About author

Director of Delphi Consulting for GDK Software USA. Many software related patents, including swipe and pattern unlock and search engines. First Silver and Gold Delphi badges on Stack Overflow Former Developer Advocate for Embarcadero Technologies. Long time fan of programming, especially with Delphi. Author, Podcaster/YouTuber, Improvisor, Public Speaker, Father, and Friend.

1 Comment

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

IN THE ARTICLES