- How to create the different types of libraries?
- Creating the main library
- Creating the secondary projects and the secondary libraries
- Including secondary libraries in the main project
- Including a secondary library in a project
- Using external libraries by programming
Using several libraries in an application
From version 18
, the use of several libraries is not recommended. We advise you to replace the secondary libraries by internal or external components.
A library is a WDL file that contains all the resources: windows, reports, classes, sets of procedures, ... This file is used by the executable or by the WEBDEV engine (for a dynamic site).
To optimize the loading of a large project in the editor (project containing hundreds of window for example), we advise you to divide this project.
To divide a large project, you can:
- use independent projects: each project generates an independent executable. These executables interact between themselves. The main inconvenient of this method is as follows: these executables do not share their resources.
- use secondary libraries:
- A main project is used to generate the main library and the executable.
- Some secondary projects ("Library" type) are used to generate the secondary libraries used by the main project. At runtime, the program opens the main library and the secondary libraries: all the resources are shared among the different libraries.
How to create the different types of libraries?
Creating the main library
The main library of an application is created:
- when creating the executable (in WINDEV and WINDEV Mobile).
- when creating the setup program (in WEBDEV).
All the components found in the current project are automatically included in this library. Some elements can be added or deleted during the creation of the library.
For more details, see:
Creating the secondary projects and the secondary libraries
To create the secondary projects:
- In the editor, create a new project of "Library" type.
- Click in the quick access buttons. Click "Project" in the wheel that is displayed. The project creation wizard starts.
- In the "Description - Project type" screen, select "Library".
- Follow the different steps of the project creation wizard.
- Include all the elements required by the project:
- share (if necessary) the analysis of the main project,
- if you have an existing one, import the windows and the reports managed by the secondary project,
- create the elements managed by the secondary project.
- Configure the options of the library: In the project explorer:
- select the project configuration corresponding to your library.
- select "Description" in the context menu.
- In the "Compatibility" tab, select the compatibility options of the library:
- Use in the WINDEV projects only or not,
- Activation of the 64-bit compilation errors,
- Activation of the Linux compilation errors.
- Create the library:
The wizard for library creation starts.
- Select the elements that will be included in the library. The library and the current project will have the same name. You can:
- Add elements ("Add" button):
Any type of file can be added to the list of elements inserted into the library: images, text files, etc.
- Delete elements ("Remove" button)
The corresponding files and their dependencies will be ignored in the library.
- Create the library from an existing library description ("WDU" button).
When creating a WINDEV or WINDEV Mobile library, a ".WDU" file of the same name is automatically created. This file contains all the references of the elements included in the library. All you have to do is select the WDU file containing the elements to take into account.
IMPORTANT: Click the "Advanced" button and check "Yes: the library can be included in other projects".
- Specify the languages found in the library. You can use:
- one or more languages associated with the project
- all project languages
- the current language only
- If your library contains classes, you have the ability to configure for each class:
- whether the class is visible: The class can be used in another project like any other project class: you will have the ability to declare an object of the class or to derive this class for example.
- whether the class is hidden: The class cannot be used in another project.
- Specify the information about the library version:
- the name of the company. For example, the name of the publisher.
- a short description. For example: "Inventory management".
- the copyright
- the version of the library. All the characters (digits and letters) are allowed. For example: "1.01A".
We advise you to:
- use a different version number whenever the library is created.
- automatically increment the last characters (digit or letter) of the version number whenever the library is created (check "Automatically increment the version at each creation").
- the version number "1.01A" will become "1.01B".
- the version number "A15Z" will become "A16A".
- Specify whether the updates by Patch must be taken into account by the library. In this case, all you have to do is copy the file corresponding to the Patch into the directory of the library. For more details, see Application patch.
- Validate the library creation (and the project backup if necessary).
Including secondary libraries in the main project
To include a secondary library in a main library, the option "Yes: the library can be included in other projects" must have been chosen during the library creation.
Including a secondary library in a project
To include a secondary library in a project:
- Select "Workshop .. Library .. External libraries".
- Add the secondary libraries that must be included in the project.
Only the classes defined as visible in the secondary library can be handled in the project. You will have the ability to declare an object of this class or to derive this class. The class is recognized in the project. The automatic completion
(if it is enabled) will propose this class. No error will occur when the project is compiled.
The classes included in a secondary library can open the windows found in the secondary library for example.
When creating the executable of the main application
, the secondary library is automatically selected and copied into the directory of the executable. This library will be automatically loaded when running the executable.
Using external libraries by programming
The main project library is automatically loaded when running the executable. If the secondary libraries have not been included in the project, you must use:
- LoadWDL to load a secondary library in the project. The elements found in the secondary library can be handled by programming (windows, reports, classes, ...).
- UnloadWDL to unload a secondary library.
If a library is closed with UnloadWDL
, the HyperFileSQL data files opened in the WDL are not automatically closed.
Any access to the HyperFileSQL data files will trigger the following error: "The XXX WDL file was unloaded". It is recommended to use HClose
on data files opened in a WDL file that will be unloaded.
Remark: In this case, the secondary library must be found in the directory of the executable and it must be included in the list of files to install when deploying the application.
This page is also available for…