Loading DLLs with Configuration Variables

Another way to load DLLs is to list them in the SHARED_LIBRARY_LIST configuration variable. SHARED_LIBRARY_LIST lets you specify a list of libraries to be automatically loaded by ACUCOBOL-GT at run time. It can be set in the environment, in the runtime configuration file, or programmatically with the SET ENVIRONMENT statement.

The library names in SHARED_LIBRARY_LIST are delimited by spaces or colons on UNIX and spaces or semicolons on Windows (like directories specified in the PATH variable). You can also specify both the name of the DLL and the calling convention to use. Any calling convention specified this way overrides the DLL_CONVENTION variable setting.

For example, to specify the stdcall calling convention for "mylib.dll", you might include the following in your configuration file:

SHARED_LIBRARY_LIST=mylib.dll@__stdcall

This indicates that every function in "mylib.dll" should be called using the stdcall convention, regardless of the DLL_CONVENTION setting.

To specify the cdecl calling convention, you might include:

SHARED_LIBRARY_LIST=mylib.dll@__cdecl

This indicates that every function in "mylib.dll" should be called using the cdecl convention, regardless of the DLL_CONVENTION setting.

If you have access to a library (".lib") file for the DLL, you can determine the calling convention for a particular function using the Microsoft COFF Binary File Dumper utility, as described in the previous section. Run "dumpbin /exports <library name>". If the function name is preceded by an underscore and followed by an at sign and a decimal number, the function expects to be called using the stdcall calling convention. If the name of the function is not followed by an at sign, then the function expects to be called using the cdecl convention.

Note that the SHARED_LIBRARY_LIST configuration variable does not load client-side DLLs for thin client applications that make calls using the CALL verb @[DISPLAY]: syntax. These applications must explicitly load the DLL by calling it with the CALL verb before calling a function within the DLL. You can, however, call DLLs on the server using SHARED_LIBRARY_LIST.

See Configuration Variables for more information on any of the configuration variables discussed in this section.

Note: To use shared libraries without CALLing them first, you can use the "-y" runtime option to place shared libraries on the command line. The runtime then uses the usual search logic to find the specified libraries when trying to resolve CALLs.