Gambas Documentation
Application Repository
Code Snippets
Compilation & Installation
Components
Controls pictures
Deprecated components
Developer Documentation
Development Environment Documentation
Documents
Error Messages
Gambas Playground
How To's
How To Change the Tab Order of GUI Controls
How To Contribute
How to Create and Open a ".gmail.txt" Archive
How to deal with Git and Gitlab concerning your Project
How to deal with Git and Gitlab for Gambas
How To Deal With Subversion for Gambas
How To Display a Chinese Character
How To Draw with gb.Cairo
How To Enter Data With gb.db.form
How To Get Gambas Web Started (1)
How To Get Started
How To Interface Gambas With External Libraries
How To make a chart with the gb.chart component
How to make a report with Gambas
How To Make KDE Run Gambas Executables Automatically
How To Open, Debug & Compile The IDE
How To Open a MySQL connection and use it
How To Open a SQLite connection and use it
How To Open a Unix ODBC connection and use it
How To Package Gambas
How To Package your Project
How To Print
How to Run Gambas and Gambas Apps on Windows using WSL
How To Run Gambas On Windows using Cygwin
How To Translate A Gambas Project
How To Translate Gambas
How To Translate The Gambas IDE (deprecated)
How To Use Parallel Port
Language Index
Language Overviews
Last Changes
Lexicon
README
Search the wiki
To Do
Topics
Tutorials
Wiki License
Wiki Manual

How to Run Gambas and Gambas Apps on Windows using WSL

Prerequisites

You have to have a basic setup consisting of the following in order for this to work.
  • Windows 10 with WSL2 installed
    • For x64 systems: Version 1903 or higher, with Build 18362 or higher.

    • For ARM64 systems: Version 2004 or higher, with Build 19041 or higher.

    • Builds lower than 18362 do not support WSL 2. Use the Windows Update Assistant to update your version of Windows

  • Ubuntu Linux installed in the WSL

There is a simplified install procedure for those who do not have the WSL and Ubuntu systems installed. You can try it out by opening a Powershell account and running wsl --install -d Ubuntu. This seems to be limited to those who are part of the insider program however.
  • An XServer client running on Windows. For example, XMin or VcXsrv.

Running GUI apps under Windows is supported since Windows 10 Build 19044+ or Windows 11.
  • Gambas must be installed

Use these instructions to install Gambas on the Ubuntu version of Linux installed in the WSL

Running Gambas

Set up a desktop shortcut that uses the following command-line string: C:\Windows\System32\wsl.exe DISPLAY=:0 LANG=en_EN.UTF-8 gambas3

Running Gambas apps

Set up a desktop shortcut that uses the following command-line string: C:\Windows\System32\wsl.exe DISPLAY=:0 LANG=en_EN.UTF-8 myprogramm.gambas

Check for Windows

In your Gambas app, you can check to see whether you are running in windows or not, and use that to decide how you are going to do things. Use this snippet of code:
Dim kernel As String
Dim isWindows As Boolean
Shell "uname -a" To kernel
If InStr(kernel, "Microsoft") Then isWindows = True

Acknowledgements

Thank you to Dmitry Bachilo for his information which led to this Howto, and to Christof Thalhofer for mentioning it.

-- John Dovey