[Gambas-user] Gambas on Windows

Admin admin at allunix.ru
Fri Jan 10 09:49:31 CET 2020

10.01.2020 14:49, Rolf-Werner Eilert пишет:
> Am 10.01.20 um 06:07 schrieb Admin:
>> I am using Gambas to write programs for Windows for quite some time 
>> now. It is excellent. Before I had to port everything to Visual 
>> Basic, then I used the way, which to this day is official - Cygwin. 
>> But for a long time now, since you don't even have to be a Windows 
>> Insider Preview member to install WSL on Windows 10, everybody can do 
>> it in one click using Windows Store, software just works. I just use 
>> simple kernel version detection like this:
>> Dim kernel As String
>> Dim isWindows As Boolean
>> Shell "uname -a" To kernel
>> If InStr(kernel, "Microsoft") Then isWindows = True
>> Knowing I am in Windows I can call any exe file I want, for example 
>> Shell("notepad.exe") just opens Windows Notepad. I can also call any 
>> console Windows command like ping.exe and pipe it right away like 
>> ping.exe | grep Destination - and it works perfectly.
>> I use Xming started with Windows startup and create .lnk Desktop 
>> Shortcuts to my graphical software simply like this:
>> C:\Windows\System32\wsl.exe DISPLAY=:0 LANG=ru_RU.UTF-8 
>> myprogramm.gambas
>> so my software written in Gambas just runs on Windows Desktop by 
>> simply double-clicking it. It's that simple
>> So, my point is: isn't it time to officialy call it a way to run 
>> Gambas in Windows instead of Cygwin? I mean I know, that Cygwin is 
>> more universal, but it also is more complicated and Windows 10 became 
>> defacto standard for Windows machines already.
>> It feels kinda lonely without any official documentation on this type 
>> of operation :-)
>> Best regards
>> Dmitry Bachilo.
>> ----[ http://gambaswiki.org/wiki/doc/netiquette ]----
> That sounds very interesting, Dmitry. Just a few questions:
> What is the graphical component you use for your programs, qt or gtk+? 
> And do you use the automatical switcher?
> What about printing - is there a way of (at least) pushing pdf files 
> into Windows' printing system?
> You write about "Windows Store". Does it mean, I need an account with 
> Mickeysoft for it?
> We have one Win10 machine here for some of these indispensible 
> programs every firm needs but which exist for Windows only. It would 
> be great if I could run one or two of our Gambas programs there.
> Last idea: Could you describe the way of installing WSL, Xming and a 
> Gambas application on a Win10 machine? As I have so few experience 
> with Windows, I wouldn't even know where to start ;)
> Regards
> Rolf
> ----[ http://gambaswiki.org/wiki/doc/netiquette ]----
Ok, so what you basically do is go to Microsoft Store which is in a 
start menu under the letter M obviously.

You probably already have an account if you got Windows installed, but 
if not, it will ask you to register, it's simple - just provide any 
email and password.

There just type Ubuntu in search bar and install Ubuntu app in one (or 
maybe two) click(s)

What will happen is you will have compact distribution of Ubuntu 
installed in Windows, it's a standard feature there nowadays. There's 
also Debian and it already has Gambas in repo, but it doesn't work, qt5 
dependency is broken.

Now, when Ubuntu is installed, you will have Ubuntu app icon in Start 
menu, wich is basically a bash shell chrooted to Programm Files 
directory where your Ubuntu infrastructure is installed. When it would 
be first run it'll ask you to enable Windows Subsystem For Linux (WSL) 
and tell you exactly how to do it, also one click more or less.

Everything else is just installing Gambas (or anything else) in Ubuntu, 
so you add a PPA, then "apt-get update" then "apt install gambas3" and 
you are ready to go, console gambas apps will now work if you run them 
from this bash console or by typing "wls <programm>.gambas" in windows 
cmd or anywhere else in Windows, even from .bat or .cmd file, or another 
program capable of "shell" operator.

Gambas in Ubuntu (at lease in Windows' repository) seems to be linked to 
QT4, and GTK3 is also there by default, so you can create and run those 
types of apps. And, as I've already said, you can run cli apps without 
any additional moves.

To run any graphical linux program in Windows 10 you need an X server. 
Just google, download and install Xming, it's free and easy to install. 
There's also an X server in Microsoft Store but it's 50 bucks so no thanks.

When XMing is installed what I do is run a configurator that creates an 
Xlaunch file. So I tell it to not create a root window, just to be ready 
to serve apps without aunthentication, and then i put this xlauch file 
in Autorun in Start menu

So now you can either specify DISPLAY=:0 in bash cli and run any 
programm from now on, or just create a basic windows shortcut with a 
line that I already provided before.

For example I have a app icon for Gambas on my desktop. The command it 
executes on double click is:

C:\Windows\System32\wsl.exe DISPLAY=:0 LANG=ru_RU.UTF-8 gambas3

it sets DISPLAY environment to work with Xmin and it sets my native 
locale, so I can see Gambas IDE in my native language.

That's it. Any software then written in gambas is run from such 
shortcuts with the same scheme: C:\Windows\System32\wsl.exe DISPLAY=:0 
LANG=ru_RU.UTF-8 myprogramm.gambas

BTW the very same way you can ran, say, Firefox, or Chrome, or any other 
linux version of graphical software that you install with apt in yout 
pseudo ubuntu. It works in Windows 10 just like that.

RedHat's Cygwin did this for years, but now Windows 10 just officially 
supports Linux binaries through WSL, so no need for any additional 
software. If you want to, say, run Apache or any other Linux 
non-graphical software - you don't even need Xming? just install Ubuntu, 
apt install your app and you are good to go. Even sshd works, but you 
have to remember that Windows 10 also has it's own SSH, so you have to 
disable it first.

Oh, and keep in mind that you can't mount anything and /dev is just 
empty, but your Windows drives are already in /mnt, so you still see all 
your Windows infrastructure and you can run Windows software from inside 
of this Linux chroot if you will

More information about the User mailing list