RAD Studio 10.4.1 is now available! Learn more. Looking for discounts? Visit our Special Offers page!
DelphiNews

Deploying FireMonkey to HTML5 with FMXLinux on WSL2

The absolutely quickest way to get started with Linux deployment from Delphi is to use the Windows Subsystem for Linux (WSL). As of Windows 10 Version 2004 (Build 19041) WSL2 includes a full Linux kernel, 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 WSL or 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 paserver running (the script above launched it), 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 with it nicely.
  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 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.

https://embt.co/3oFnZVW


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

Chief Developer Advocate for Embarcadero Technologies.
Related posts
C++Delphi

Ultimate Compression Toolkit For Delphi And C++ Builder Developers

CodeDatabaseDelphi

Hit The Ground Running With Windows Native MongoDB Database Sample Apps For Delphi

C++DelphiRAD Studio

Beautiful Responsive Home Screen UI Templates For FireMonkey Available For Free Via GetIt In The IDE

Delphi

Flexible VCL Style Utils Library Made It Easy To Modernize The Dev-C++ Dialogs With VCL Styles In Delphi

1 Comment

Leave a Reply

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

IN THE ARTICLES