A question about libraries

Post Reply
bill-lancaster
Posts: 32
Joined: Tuesday 26th September 2017 3:17pm

A question about libraries

Post by bill-lancaster » Saturday 04th August 2018 9:28am

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: 16
Joined: Wednesday 05th April 2017 6:07pm

Re: A question about libraries

Post by vuott » Saturday 04th August 2018 12:34pm

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

bill-lancaster
Posts: 32
Joined: Tuesday 26th September 2017 3:17pm

Re: A question about libraries

Post by bill-lancaster » Thursday 09th August 2018 12:37pm

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

stevedee
Posts: 85
Joined: Monday 20th March 2017 6:06pm

Re: A question about libraries

Post by stevedee » Thursday 09th August 2018 5:19pm

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: 16
Joined: Wednesday 05th April 2017 6:07pm

Re: A question about libraries

Post by vuott » Thursday 09th August 2018 5:37pm

bill-lancaster wrote:
Thursday 09th 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 ?

bill-lancaster
Posts: 32
Joined: Tuesday 26th September 2017 3:17pm

Re: A question about libraries

Post by bill-lancaster » Friday 10th August 2018 7:53am

No, all .gambas
Yes, the obvious way is to have only one library.

vuott
Posts: 16
Joined: Wednesday 05th April 2017 6:07pm

Re: A question about libraries

Post by vuott » Friday 10th August 2018 10:11am

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).

bill-lancaster
Posts: 32
Joined: Tuesday 26th September 2017 3:17pm

Re: A question about libraries

Post by bill-lancaster » Friday 10th August 2018 10:56am

Yes, that's fine but if LibA needs a function in LibB?

vuott
Posts: 16
Joined: Wednesday 05th April 2017 6:07pm

Re: A question about libraries

Post by vuott » Friday 10th August 2018 6:11pm

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".

bill-lancaster
Posts: 32
Joined: Tuesday 26th September 2017 3:17pm

Re: A question about libraries

Post by bill-lancaster » Tuesday 14th August 2018 6:19am

Thanks vuott, that works.

Post Reply