[Gambas-user] Creating a library

Doriano Blengino doriano.blengino at ...1909...
Thu Sep 4 16:39:06 CEST 2008


gambas at ...1938... ha scritto:
> Am Donnerstag, 4. September 2008 14:33:03 schrieb Doriano Blengino:
>   
>> gambas at ...1938... ha scritto:
>>     
>>> Am Mittwoch, 3. September 2008 10:56:37 schrieb gambas at ...1938...:
>>>       
>>>> Hi List!
>>>>
>>>> I've written a kind of library, where I droped my standard routines. At
>>>> the moment, I have to compile this class every time with my projects.
>>>>         
>> When you speak about "compile this class every time", I think your
>> libray is a gambas source code. If it is so, then you can not compile it
>>     
Make a (dummy?) project with your libray in it; give it a meaningful name.
Edit the library source: put a "EXPORT" alone in a line at the beginning:

    ' Gambas module file

    EXPORT 

    PUBLIC SUB printit(st AS String)

      PRINT st

    END 

Run the project, or compile it.
Go to the project properties (General, Options, Components...); in the 
"Options" tab set "This project is a component" to YES; further tabs 
should appear on the right of the window (Provides and Requires).
Go the tab "Provides", and click on the line starting with your library 
name, under the column "Type", and set "Class".
Confirm with "OK".

Next, create an executable: Main menu/Project/Create/Executable; a 
window will open asking for a location.
For this kind of things, I use the same path as the project, but could 
be better to choose a location accessible by other users too, I don't 
know. Before continuing, expand the last item in the window named 
"Options": two checkboxes will appear. Check the "Install components in 
the user directory" or something similar.

Confirm with OK.

Quit Gambas. In your home directory you shoud find two directories:

  .local/lib/gambas2/
  .local/share/gambas2/

with things inside them (symbolic links to the executable you created 
before).
If you don't find ~/.local, or one of the other subdirectory, try to 
create them and repeat the create executable step. I don't remember 
whther gambas creates them automatically or it expects them to be there.

Restart gambas, open/create another project (not the old one, I 
suppose...), go to the project properties under the section 
"Components". In the list of available components, you should find a 
line containing the name of the project you did in the first step. Check 
it, and now in your project you can use the methods declared in your 
library.
Referring to the source code above, I called that module "alib", and put 
it inside a project "provalib". So, in another project, I can check the 
line "provalib", and the methods are accessible by writing "alib.printit()".

Some notes:

I use gambas 2.0.0, quite an old version, with italian localization. 
Your version could be a little different...

I am testing what I am just writing to you, and it works. But there 
could be better/preferrable methods.

Good luck, hope this solves.

Cheers,
Doriano.




More information about the User mailing list