[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Is it possible/acceptable to create a component in Gambas that depends on a shared library?


On 2/13/26 06:58, gbWilly wrote:
On Friday, February 13th, 2026 at 15:40, Lee<t.lee.davidson@xxxxxxxxx> wrote:

On 2/12/26 1:04 PM, gbWilly wrote:
You did use Exec "getuid" for the first 4 functions in your example.
I changed this, because, even though the result happens to be the same, it seems you need to Exec 3 other functions from the library instead for the last 3 functions (see red marked section on screenshot). Is my assumption there correct?
Yes, your assumption is correct. I goofed. I had typed in the first Extern declaration and then copied and pasted it three
times. I changed the Gambas function name on those three but not the library's function name. Good catch.
I suspected copy/paste was the culprit somehow :-)
I also managed to use a simple function like basename and interface with it (see yellow marked section on screenshot).
It's good to see that you successfully implemented a different external function call. You see that it /can/ be quite simple. It
will get more complex when you need to use pointers.
You happen to have an example function from the same library for a demonstration?
Seeing the C library documentation and a translate to Gambas really helps me a lot in forming an understanding.

One thing to keep in mind, for future reference, is that Gambas can interface only with libraries written in C and not in C++
(unless the library does not use any C++ structures or capabilities that are not C compatible). If there is a particular library
with which you'd like to interface and it is written in C++, look to see if it has a C-wrapper.


Good to know.

If you have any questions, feel free to ask here. Have fun!
See above :-)

Thanks again,

gbWilly

GambOS
Gambas3 for Debian/Ubuntu

...there is always a Catch if things go wrong!


This youtube video , covers what happens for mixed interpreter and library code.

The video <https://www.youtube.com/watch?v=RnBOOF502p0>

It may not focus on Gambas, but does seem to explain the underlying mechanisms well.

Sorry it is in English!

--
~~~~ Brian

Attachment: OpenPGP_0x78BFB26402F48419.asc
Description: OpenPGP public key

Attachment: OpenPGP_signature.asc
Description: OpenPGP digital signature