jbaseico.jpg (1294 bytes) Building DLLs and shared objects

Back to Knowledge Base Back to Knowledge Base Articles

When you CATALOG a subroutine in jBASE, a DLL (Windows) or shared object (Unix) is created. The name and size of the DLL is controlled by parameters in the jLibDefinition file. As each subroutine is cataloged, the target DLL increases in size. When it reaches the maximum size as specified in jLibDefinition, a new DLL is created. So it can be seen that the set of subroutines contained by a DLL depends on the the order that the subroutines are cataloged in. As a result  the developer using CATALOG does not have precise control over which subroutines get built into a DLL. Although this is not a problem, there are occasions where a developer wants a DLL to contain a specific set of subroutines. This article describes how to achieve this.

If you use the "-v" option on CATALOG, you can see that the jBuildSLib command is used internally to build the DLL. jBuildSLib can be used directly by developers to build a DLL. However, in order to use jBuildSLib the jbc command must first be used to create the object files. This command assumes the convention that jBC (Basic) programs are files in a directory and have the extension ".b".

The approach to building a DLL is best illustrated by an example for the following subroutines.

CUSTADD.b
CUSTDELETE.b
CUSTINDEX.b
CUSTLOAD.b
CUSTPROFILE.b
CUSTVERIFY.b

Windows

1. Create the object input files

jsh devel ~\src -->jbc -c CUSTADD.b CUSTDELETE.b CUSTINDEX.b CUSTLOAD.b CUSTPROFILE.b CUSTVERIFY.b

This creates the subroutine objects CUSTADD.obj, CUSTDELETE.obj CUSTINDEX.obj CUSTLOAD.obj CUSTPROFILE.obj CUSTVERIFY.obj

 

2. Build a DLL called CUSTSUBS.dll

jsh devel ~\src -->jbuildslib -o CUSTSUBS.dll CUSTADD.obj, CUSTDELETE.obj CUSTINDEX.obj CUSTLOAD.obj CUSTPROFILE.obj CUSTVERIFY.obj

This creates the files CUSTSUBS.def, CUSTSUBS.dll, CUSTSUBS.exp, CUSTSUBS.lib.

 

3.

In order that the subroutines can be called at runtime, the dynamic-link library (CUSTSUBS.dll) and the library definition file (CUSTSUBS.def) must be placed in a directory (by convention called "lib") that is included in JBCOBJECTLIST.

 

 

Unix

1. Create the object input files

jsh devel ~/src -->jbc -c CUSTADD.b CUSTDELETE.b CUSTINDEX.b CUSTLOAD.b CUSTPROFILE.b CUSTVERIFY.b

This creates the subroutine objects CUSTADD.o, CUSTDELETE.o CUSTINDEX.o CUSTLOAD.o CUSTPROFILE.o CUSTVERIFY.o

 

2. Build a shared object called CUSTSUBS.dll

jsh devel ~/src -->jBuildSLib -o CUSTSUBS.so CUSTADD.o, CUSTDELETE.o CUSTINDEX.o CUSTLOAD.o CUSTPROFILE.o CUSTVERIFY.o

This creates the files CUSTSUBS.so, CUSTSUBS.so.el.

 

3. In order that the subroutines can be called at runtime, the shared object (CUSTSUBS.so) and the export library (CUSTSUBS.so.el) must be placed in a directory (by convention called "lib") that is included in JBCOBJECTLIST.

 

Bear in mind that if a subroutine is changed, the relevant subroutine must be recompiled (using jbc) and then the DLL must be rebuilt so that the change is reflected.The complete set of subroutine object files is required to rebuld the DLL. This is exactly what happens when a subroutine is cataloged or decataloged.


Last modified on March 18 2003