Running Gambas Programs in Windows

From PigaLore
Jump to navigationJump to search

Most software developed by Piga Software are written in Gambas, and as a result they require the Gambas runtime. Unfortunately at this time there is no native support for running the Gambas runtime under Microsoft Windows. However, there are many solutions available for this problem.

Windows Subsystem for Linux[edit]

Mosquito running through WSL2 on Windows 11

Windows Subsystem for Linux

From 2016 this was usually done using an X terminal emulator such Mobaxterm on Windows as WSL did not support X11 graphics directly until the updates released with Windows 11 in 2021. Given it is an officially supported part of modern Windows, it is the best option for out of the box use, but is only available from Windows 10 or later. Our own testing has found this system fairly performant, albeit with issues with mouse focus.

To install WSL, load up Powershell (CMD Prompt) in administrator and type:

  wsl --install

Once Ubuntu is installed (by default, others are available as well), type:

  sudo apt update

This will make the apt package manager work. You can then install Gambas.

  sudo apt install gambas3*

This will install Gambas and all of its components.

You can then run Gambas applications or the IDE.

Running through Cygwin[edit]

Hull Breach running through Cygwin on Windows 11

Cygwin

Once only available for command line Gambas programs, since 2016 it is now possible to run graphical, feature rich programs. Therefore, this is the recommended method as of version 3.9.2. Additional instructions were posted here. Our own testing has found the performance to be lower than of WSL, but with greater compatibility. It is also usable on a greater range of Windows installs. An official package for Cygwin is available maintained by Bastian Germann.

Porting to another language[edit]

If you are a programmer and you feel up to this challenge then you may want to consider this option. A list of GUI based development environments for Linux can be found here and here.

  • Advantages
    • If written properly software should be stable and efficient
    • Once ported software should be easy to set up for users no matter what their technical background.
  • Disadvantages
    • Will require strenuous bugfixing and testing
    • Difficult to provide program updates over two separate codebases

Although this is theoretically possible with any language, some are more similar to Gambas than others.

Visual Basic[edit]

Attempted port of Free Empires to Windows XP with VB .NET 2005 Express
Original Free Empires Source Release in Gambas from Fedora

The most obvious candidate for porting is Visual Basic .Net as it is a common BASIC derivative with a form designer that works well in modern versions of Windows. Also VB.net has a stripped down "free for use" version (Community, previously Express), and shares certain syntax supported in Gambas (such as -= or += shorthand and zero indexed arrays). If you have the need, you may also consider using the classic Visual Basic (presumably version 6) for legacy versions of Windows. Other commercial BASIC versions like PureBasic and Xojo, as well as the freeware RapidQ, are also options.

  • Advantages
    • Common BASIC heritage and similar form designers
  • Disadvantages
    • Forms have to be recreated from scratch, and not all form controls are shared between Gambas and either VB or VB .Net
    • Syntax differences from both languages are varied
    • Visual Studio is proprietary software and Windows only; limited compatibility via Mono.
    • As of 2020, Microsoft is maintaining but no longer actively developing the .Net version of the language, although the third-party Mercury exists.
    • The original variant was discontinued by Microsoft way back in 2008, with legacy support attempted by ModernVB, RAD Basic and twinBASIC.

FreeBASIC[edit]

Although descended from the earlier QBasic rather than Visual Basic, the FreeBASIC language features numerous modernizations including partial support for object-oriented programming. Although primarily used in pure markup, there exists a few visual IDEs, one of the most active currently in English and cross-platform being VisualFBEditor. The presently discontinued Basic For Qt are also options (HBasic meanwhile was also Linux only), as well as markup based variants of BASIC such as wxBASIC or SdlBasic and Basic4GL. QB64 also has an event driven graphical IDE called InForm.

  • Advantages
    • Free software and crossplatform
    • Similar BASIC style syntax
    • Porting can be done from a common Linux installation (running side-by-side)
  • Disadvantages
    • No unified interface for GUIs, with toolkit components in visual IDEs somewhat limited
    • Smaller community than other options
    • More archaic syntax with limited object orientation

Lazarus[edit]

Original Mosquito in Gambas
Attempted port of Mosquito to Lazarus

Main Article: Crustacean of Bethany

In terms of feature set, the IDE most similar to that of Gambas available in the free software world is arguably Lazarus, an environment powered by Free Pascal. Similar to how Gambas was inspired by Visual Basic, Lazarus was inspired by the very similar Delphi for Object Pascal. Theoretically one could also port a Gambas program to Delphi itself, for which there does exist a freeware community version, or the even older Borland Kylix if one does not care about using an open source foundation.

  • Advantages
    • Very similar fundamental graphical component models
    • Both are free software languages
    • Both are object oriented and event driven languages
    • Porting can be done from a common Linux installation (running side-by-side)
    • Better support for more recent OpenGL versions
  • Disadvantages
    • Forms have to be recreated from scratch
    • Syntax differences from both languages are varied (Pascal and BASIC are distinct language families)
    • Lazarus currently defaults to the antiquated GTK2 on Linux (which needs to be installed on Windows for 1:1 parity)

Python[edit]

Godot[edit]

The Godot 4 engine features a new Tilemap system similar in function to the Gambas Tile System, and has a handful of common UI controls like buttons, labels, text boxes, and containers.

  • Advantages
    • Both are free software development environments
    • Porting can be done from a common Linux installation (running side-by-side)
    • Does not require porting of rendering and physics systems
    • Utilizes modern frameworks, namely OpenGL ES and since version 4 also Vulkan
  • Disadvantages
    • Scenes have to be recreated from scratch, although tile maps may be converted
    • Syntax differences from both languages are varied (GDScript is based on Python)
    • GUI controls far less robust

Using SSH Forwarding[edit]

A stated on the Gambas Documentation you can used SSH Forwarding to run Gambas programs in Windows. The page has it nicely layed out for using the NX protocal.

You can also use PuTTY and Xming (or CygwinX) to so the same thing. On the Linux server you need SSH installed and the port opened if you are running a firewall (the default is 22). On the Windows computer you need PuTTY and an X11 server, like Xming.

One you have the Gambas software installed on Linux run the X11 server and PuTTY on the Windows computer. Make sure PuTTY is set to allow X11 forwarding too your server. Then connect and login to the linux server.

One you have done that run the program using the relevant command.

E.g. Gambas_Example

Things to add to tutorial:

   Sound Forwarding with PulseAudio
  • Advantages
    • actually running on a Linux server so is fully compatible

Disadvantages

    • can be slow depending on network connectivity
    • limited support for devices
    • requires a separate computer

Cloud streaming[edit]

Gambas is included on the rollApp cloud streaming service, although the free tier is very limited in functionality.

Running through Linux virtual machines[edit]

For this option you need a Virtualisation environment to run a "virtual copy" of Linux on top of Windows. There are several available including Parallels, VMWare, Virtual PC, and VirtualBox. For this documentation we are going to use Sun Microsystems VirtualBox platform. The procedure should be similar for other platforms however, you may need to consult documentation specific to it. Microsoft's Virtual PC should work but is not recommended since there is no official support for Linux guests.

https://blog.desdelinux.net/en/gnulinux-y-gambas3-ejecutandose-en-windows/

  • Advantages
    • No code changes
  • Disadvantages
    • Difficult for non-technical users
    • Can be resource intensive
    • Separates your program from the user's native Windows setup

coLinux[edit]

Snake example under coLinux on Windows XP

coLinux is actually a specialized cooperative virtualisation environment for seamlessly running Linux under a Windows kernel. As shown from the accompanying screenshot, Piga Software has successfully tested this once using andLinux; as has Daniel Campos.

  • Advantages
    • Seamlessly run Gambas, or any Linux software, under Windows
  • Disadvantages
    • Extremely difficult for non-technical users
    • Has not been recently maintained since April 9, 2011
    • Less choice of distributions than traditional virtualization