Gambas Documentation - /doc/library

/doc/library

# Libraries

- Introduction

- How to make a library from a project?

- How to use a library in a project?

- How and where to install a library?

## Introduction

Gambas libraries are Gambas executables that can be used by a project almost exactly like a component.

But there are some differences and some tricky points that require a bit of attention.

The most important one is the following: A Gambas executable can use a library only if they are stored in the same directory than the project that uses it.

## How to make a library from a project?

Just create a normal Gambas project.

In the project properties dialog, go to the 'Options' tab and set 'This project is a component or library' to 'Yes':

Then you can open the component properties dialog.

Exactly like a component, you can see the exported class and you can define the features and components the library needs.

Only the classes marked with the EXPORT keyword will be exported and visible to the project using that library.

Then make the project executable.

## How to use a library in a project?

Open the project property dialog and go to the 'Libraries' tab.

There you can select all libraries used by your project by specifying the absolute path of their executable.

## How and where to install a library?

When you run a project from the IDE, the libraries it uses are located by using their absolute path, as specified in the 'Libraries' tab of the project property dialog.

But when you run the project executable, the libraries it uses then must be located in the same directory.

If a library is not found, then it is searched in `/bin` and `/usr/bin` as last resort.

So, contrary to a component, a library must be packaged exactly like a normal program, so that it is installed in a place where all project can find it.