You can store the objects used in your PowerBuilder application in more than one library and, when you run the application, dynamically load any objects that are not contained in the application's executable file. This allows you to break the application into smaller units that are easier to manage and makes the executable file smaller. You do this by using dynamic libraries. If you compile using Pcode, PowerBuilder builds PowerBuilder dynamic libraries (PBD files). If you use machine code, PowerBuilder builds Dynamic Link Libraries (DLL files).
When you distribute your application to users, you distribute the executable, the dynamic libraries, and PowerBuilder runtime DLLs. For more information about deployment and a list of PowerBuilder runtime DLLs, see Deploying Applications and Components in Application Techniques.
Dynamic library names
PowerBuilder dynamic libraries are given the name of the PBL with the extension .pbd. For example, the Pcode library built from test.pbl is named test.pbd.
Machine-code dynamic libraries are given the extension .dll. For example, the machine-code library built from test.pbl is named test.dll.
Reducing the size of dynamic libraries
When PowerBuilder builds a dynamic library, it copies the compiled versions of all objects from the source library (PBL file) into the dynamic library.
The easiest way to specify source libraries is simply to use your standard PowerBuilder libraries as source libraries. However, using this technique can make your dynamic libraries larger than they need to be, because they include all objects from the source library, not just the ones used in your application. You can create a PowerBuilder library that contains only the objects that you want in a dynamic library.
To create a source library to be used as a dynamic library:
-
In the Library painter, place in one standard PowerBuilder library (a PBL file) all the objects that you want in the dynamic library.
-
If you need to create a new library, select Entry>Library>Create from the menu bar, then drag or move the objects into the new library.
-
Make sure the application's library search path includes the new library.
Multiple dynamic libraries
You can use as many dynamic libraries as you want in an application. To do so, create a source library (PBL file) for each of them.
Specifying the dynamic libraries in your project
When you define your project, you tell PowerBuilder which of the libraries in the application's library search path will be dynamic by checking the PBD or DLL check box next to the library name in the Project painter.
Including additional resources for a dynamic library
When building a dynamic library, PowerBuilder does not inspect the objects; it simply copies the compiled form of the objects into the dynamic library. Therefore, if any of the objects in the library use resources (pictures, icons, and pointers)—either specified in a painter or assigned dynamically in a script—and you do not want to provide these resources separately, you must list the resources in a PowerBuilder resource (PBR) file. Doing so enables PowerBuilder to include the resources in the dynamic library when it builds it.
To reference additional resources:
-
List the resources in a PBR file, as described in Using PowerBuilder resource files.
-
Use the Resource File Name box in the Project painter workspace to reference the PBR file in the dynamic library.