Page 1 of 1

A question about libraries

Posted: Saturday 4th August 2018 9:28am
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

Re: A question about libraries

Posted: Saturday 4th August 2018 12:34pm
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

Re: A question about libraries

Posted: Thursday 9th August 2018 12:37pm
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

Re: A question about libraries

Posted: Thursday 9th August 2018 5:19pm
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!

Re: A question about libraries

Posted: Thursday 9th August 2018 5:37pm
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 ?

Re: A question about libraries

Posted: Friday 10th August 2018 7:53am
by bill-lancaster
No, all .gambas
Yes, the obvious way is to have only one library.

Re: A question about libraries

Posted: Friday 10th August 2018 10:11am
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).

Re: A question about libraries

Posted: Friday 10th August 2018 10:56am
by bill-lancaster
Yes, that's fine but if LibA needs a function in LibB?

Re: A question about libraries

Posted: Friday 10th August 2018 6:11pm
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".

Re: A question about libraries

Posted: Tuesday 14th August 2018 6:19am
by bill-lancaster
Thanks vuott, that works.