[Gambas-user] Use of a Gambas library in a module

T Lee Davidson t.lee.davidson at gmail.com
Mon Oct 22 20:50:54 CEST 2018


Yes, Gianluigi, that code does work.

Interestingly, with the library located within the project directory, I was able to load it with, literally,
'Component.Load("/doesnotexist/myLibrary")'. But, it would not find it with the path specified as "myLibrary", "../myLibrary",
or "./myLibrary".

Apparently, since it could not be found at a path that does not exist, Gambas then applied the Library Search Paths [0] finding
the library in the first path searched, the project directory. However, if the library is not in the project directory and since
Gambas does not know its vendor, the library cannot be found in (regexp expressed):
($XDG_DATA_HOME | ~/.local/share)/gambas3/lib/<vendor>/<name>:<version>.gambas
or any of the other search paths since they also rely on <vendor>.


And that brings up a question.

Reference [0] states, "When a project that depends on a library is executed, the library executable is searched for in the
following paths [...]"

Now, for a project to 'know' that it depends on a library, the library must be specified in the Project properties Libraries
tab, correct? And, if that is done, then the project would already 'know' the location of the library.

So then, why the need for search paths?

If the search paths are to facilitate dynamic loading of libraries, then all but one path would be guaranteed to fail to produce
results since the vendor of the library would not be known unless somehow specified.

Is it supposed to be possible to load a library by specifying its name as "<vendor>/<name>" or "<vendor>/<name>:<version>" [ie.
Component.Load("gambasbook_de/myLibrary)]?


[0] http://gambaswiki.org/wiki/doc/library#t2


___
Lee

P.S. Gianluigi, calling the Main method of Class.Load[ed] Module1 also works as:
  Dim Module1 As Class

  Module1 = Class.Load("Module1")
  Object.Call(Module1, "Main")


On 10/21/18 4:31 PM, Gianluigi wrote:
> Hans, Lee,
> this attached code, here works.
> 
> Regards
> Gianluigi
> 
> Il giorno dom 21 ott 2018 alle ore 20:48 T Lee Davidson <t.lee.davidson at gmail.com <mailto:t.lee.davidson at gmail.com>> ha scritto:
> 
>     Actually, "/usr/lib/gambas3/" would be the *system* path where all the components are stored. You get that particular path
>     string with Component.Path.
> 
>     When you make an executable of a library (in this case resulting in "myLibrary.gambas"), a copy is also automatically placed in
>     the *user* path:
>     <Desktop.DataDir>/gambas3/lib/<vendor_name>/<file_name> (filename in this case is "myLibrary:0.0.gambas").
> 
> 
>     ___
>     Lee
> 
> 
>     On 10/21/18 10:42 AM, Gianluigi wrote:
>     > As suggested by Benoit and Jussi, the Library should be copied inside the project, then in Sub Open you writs:
>     >
>     >   Dim sPath As String
>     >   sPath = "/usr/lib/gambas3/myLibrary:0"
>     >   Component.Load(sPath)
>     >
>     > and with help from this lesson [0], completes the project.
>     >
>     > Regards
>     > Gianluigi
> 
>     ----[ Gambas mailing-list is hosted by https://www.hostsharing.net ]----
> 
> 
> 
> ----[ Gambas mailing-list is hosted by https://www.hostsharing.net ]----
> 


More information about the User mailing list