Creation of a plugin for Gambas

Hello, I use Gambas for many years for the creation of application. I also participate from time to time in the development of the project gambas. I would like to find help to allow users of this RAD to generate snap packets.

I’m looking for several hours but I can not find really clear about the creation of plugin like python (both languages use an interpreter).

If you could kindly orient me … thank you

gambas (since 2001) => http://gambas.sf.net

1 Like

This would be great! Essentially a snap is just a squashfs file containing the application, supporting libraries and a little metadata. if you can identify what the necessary libraries are then you could generate a snapcraft.yaml template, and create the snap by running snapcraft. I’d love to help with this. I’ve not used gambas in anger before. If you have some sample code for an application which I could build in gambas, I could point you in a good direction.

1 Like

1016/5000

An example of a program in Gambas? I would say that the most representative at first is the IDE of Gambas. The code is in the source. One of the difficulties of gambas during these last ten years was precisely the evolution of dependencies … very active. Even if we avoided at best to break the codes. Snap would allow a gambas program to survive beyond the evolution of the linux ecosystem or gambas. With regard to dependencies: A gambas program uses libraries written in C or C ++ linked to third-party libraries (eg QT, GTK, SDL, MYSQL, sqlite etc … dbus) or written in gambas and sometimes using external resources (ex: gb. scan use scanimage). We already generate the necesary for the generation of standard packages (rpm, deb, tarball, etc … via the IDE) So I think this will not be difficult to get it working.

To try Gambas you need to use this ppa or git compilation because Ubuntu repository is far to be up to date for gambas. I’ve added the whole libs to install for compilation for 19.04 and 19.10 in the ubuntu part

Usefull link: http://gambaswiki.org/wiki/install/ubuntu

and some uses of gambas : http://gambaswiki.org/wiki/app

Well sorry to be so long :slight_smile:

1 Like

Thanks, I’ll investigate and get back to you soon.

1 Like

So as a first step I took a look at making a snap of Gambas3 itself. Here’s the yaml. Unfortunately it segfaults on launch. Looking at the strace it seems to be looking for binaries which are outside the snap.

ioctl(0, TCGETS, {B38400 opost isig icanon echo ...}) = 0
fcntl(0, F_GETFL)                       = 0x402 (flags O_RDWR|O_APPEND)
ioctl(1, TCGETS, {B38400 opost isig icanon echo ...}) = 0
fcntl(1, F_GETFL)                       = 0x402 (flags O_RDWR|O_APPEND)
ioctl(2, TCGETS, 0x7ffce73cf2c0)        = -1 ENOTTY (Inappropriate ioctl for device)
fcntl(2, F_GETFL)                       = 0x1 (flags O_WRONLY)
getcwd("/home/alan/Source/personal/gambas", 4096) = 34
lstat("/usr/bin/gbx3", 0x7ffce73cf308)  = -1 ENOENT (No such file or directory)
--- SIGSEGV {si_signo=SIGSEGV, si_code=SEGV_MAPERR, si_addr=NULL} ---
+++ killed by SIGSEGV (core dumped) +++
error: signal: segmentation fault

It seems that there is a hard link in one of the files in relation to the components, I just contacted the developer to understand the reason … and as soon as I have the answer, I come back to you.

If I understand a little about how snap works, the links must be relative, right?

#define GAMBAS_LINK_PATH “/usr/bin/gbx” GAMBAS_VERSION_STRING

const char *FILE_find_gambas(void)
{
	const char *path;

	path = getenv("GB_PATH");

	if (!path || !*path)
	{
		if (FILE_exist(GAMBAS_LINK_PATH))
		{
			path = FILE_readlink(GAMBAS_LINK_PATH);
			if (!path)
				path = GAMBAS_LINK_PATH;
		}
		else
		{
			path = GAMBAS_PATH "/gbx" GAMBAS_VERSION_STRING;
		}
	}

	return path;
}

So the GB_PATH environment variable must be defined with the bin place prefix. Is there a way to do that dynamiquely ?

That helps, yes, you can specify environment variables in the yaml.

apps:
  gambas3:
    environment:
      GB_PATH: "$SNAP/bin"
    command: bin/gambas3

This fixes the segfault. However it’s now looking for something else.

$ snap run gambas3
gbr3: unable to load component: gb.image

So I suspect there may be other elements we need to locate?

yes … it will be usefull to me to see the full structure generated by the expanded snap. I need to know if the components are generated. If yes, then I will see for the locate. Normally gbr3 look in :

#define GAMBAS_LIB_PATH “lib/gambas” GAMBAS_VERSION_STRING #define GAMBAS_LIB64_PATH “lib64/gambas” GAMBAS_VERSION_STRING

so : /usr/lib/gambas3 on my system

Here’s the contents of the snap https://paste.ubuntu.com/p/bXddF2B5rF/
Where squashfs-root would be mounted under /snap/gambas3/current (known as $SNAP at runtime).

Well so the gambas libs are right compiled and is the right place. I need to understand why the interpreter can’t find them. Maybe another environment variable or a problem in relative path solving

I’m trying to build a snap of a very small gambas project. This is my current .yaml

I get a gbc3: error: Component not found: gb

when I try to compile the project. Any advice would be great.

An assist to get you to the next step :smiley: https://github.com/lapisdecor/fight-climate-change/pull/1

1 Like

In your snapcraft.yaml :
stage-packages:
- gambas3-gb-form
- gambas3-gb-image
- gambas3-runtime
- gambas3-gb-qt5
#- gambas3-dev
#- gambas3-ide

gambas3-gui is provided by runtime but need at least a toolkit gtk2 or gtk3 or Qt4 or Qt5.

gambas3-dev is just for compiling the project but not to run it (it provide gbx3, gbc3, gba3)

But where the binary of the gambas project is generated ?

1 Like

I just updated my snapcraft.yaml. It runs the archived file but then fails with:
gbx3: warning: cannot switch to language ‘pt_PT.UTF-8’: No such file or directory. Did you install the corresponding locale packages?
gbr3: unable to load component: gb.image

I haven’t tried yet to add gambas3-gb-qt5.
the file is compiled and archived and then the executable is placed in /usr/bin

Here is my the link to my yaml: here.

I need to find why it can’t load gb.image and if it is correctly loaded

and first why I’m not able to make even a simple snap on my machine :angry:

On my case gb.image.so and gb.image.so.0 are placed in /snap/fight-climate-change/current/usr/lib/gambas3 when the snap is installed. Should there also be a gb.image.gambas?

Make a try with :

apps: fight-climate-change: environment: GB_PATH: “$SNAP/bin” command: ./usr/bin/fight-climate-change.gambas

And no need of gb.image.gambas … the .so is the shared lib :slight_smile:

I got the same result, I also did try other path variants also with no success.

I’m querying the Gambas dev to get more details about this error message.