A question about libraries

Post your Gambas programming questions here.
Post Reply
bill-lancaster
Posts: 190
Joined: Tuesday 26th September 2017 3:17pm
Location: NW England

A question about libraries

Post by bill-lancaster »

Example:-
I have a library (LibDb) that deals with database functions. Some of those functions need to call functions held in another library(LibXX).

Incorporating LibXX in LibDb causes an error :-

Code: Select all

"Cannot load LibXX: unable to load LibXX
Any advice would be welcome
vuott
Posts: 262
Joined: Wednesday 5th April 2017 6:07pm
Location: European Union

Re: A question about libraries

Post by vuott »

Hello,
3 questions:

1) What are these external functions?
2) Are you "translating" into Gambas a code already written in C ? If "yes", what ?
3) Is it possible to have some Gambas code that reproduces that problem?

vuott
Europaeus sum !

Amare memorentes atque deflentes ad mortem silenter labimur.
bill-lancaster
Posts: 190
Joined: Tuesday 26th September 2017 3:17pm
Location: NW England

Re: A question about libraries

Post by bill-lancaster »

Actually, it's not that complicated.
Make a simple runtime Gambas library MyLibA and another one, say MyLibB.
MyLibB has functions that I'd like to call from MyLibA. The IDE allows MyLiB to be installed. The error occurs at runtime.
I'm using these libraries locally, i.e. on the same PC
Thanks for the reply
User avatar
stevedee
Posts: 518
Joined: Monday 20th March 2017 6:06pm

Re: A question about libraries

Post by stevedee »

I think I know the problem that you describe. I have never been able to specify 2 dependent libraries.

I can only offer you a work-around, which is to include the functions from the second library into the first, and then recompile this 'super' library.

As an example, see my post: https://captainbodgit.blogspot.com/2014 ... x2lcd.html ...about half way down the page.

However, there must be a way to get this to work properly!
vuott
Posts: 262
Joined: Wednesday 5th April 2017 6:07pm
Location: European Union

Re: A question about libraries

Post by vuott »

bill-lancaster wrote: Thursday 9th August 2018 12:37pm Make a simple runtime Gambas library MyLibA and another one, say MyLibB.
Excuse me,
so we have a " MyLibA.gambas " libray and a " MyLibB.so " library ?
Europaeus sum !

Amare memorentes atque deflentes ad mortem silenter labimur.
bill-lancaster
Posts: 190
Joined: Tuesday 26th September 2017 3:17pm
Location: NW England

Re: A question about libraries

Post by bill-lancaster »

No, all .gambas
Yes, the obvious way is to have only one library.
vuott
Posts: 262
Joined: Wednesday 5th April 2017 6:07pm
Location: European Union

Re: A question about libraries

Post by vuott »

Well,
we have a main program and 2 .gambas libraries (libA and libB), containing Gambas code.

Main program has to call a function in libA, this function has call a function in libB.

In Project-->Property-->Libraries-->Add of main program you have to add both libraries (that is: libA and libB).

In this way, in your main program you can call only the function of libA (...that'll call the libB function).
Europaeus sum !

Amare memorentes atque deflentes ad mortem silenter labimur.
bill-lancaster
Posts: 190
Joined: Tuesday 26th September 2017 3:17pm
Location: NW England

Re: A question about libraries

Post by bill-lancaster »

Yes, that's fine but if LibA needs a function in LibB?
vuott
Posts: 262
Joined: Wednesday 5th April 2017 6:07pm
Location: European Union

Re: A question about libraries

Post by vuott »

bill-lancaster wrote: Friday 10th August 2018 10:56am but if LibA needs a function in LibB?
You have to load LibB.gambas in LibA.gambas (they must reside in the same folder, in the same path), and then you have to load both .gambas libraries, libA.gambas and libB.gambas, in main program.

Obviously the codes of the .gambas libraries must be preceded by the key-word "Export", and the functions of the .gambas libraries must be declared as "Public".
Europaeus sum !

Amare memorentes atque deflentes ad mortem silenter labimur.
bill-lancaster
Posts: 190
Joined: Tuesday 26th September 2017 3:17pm
Location: NW England

Re: A question about libraries

Post by bill-lancaster »

Thanks vuott, that works.
Post Reply