Interfacing with third party DLLs and shared objects
To interface with an external DLL, or shared object, one developedwith a different system, you should make sure your DLL supplier provides you withthe following.
- Windows only. A resolution LIB file for the DLL
- The DLL/shared object itself.
- An interface file for the symbols exported by the DLL. If this is not provided
in your native language then you will have to translate it to your native language.
When you translate the implementation body of this module you will not implement
the procedures since the code is actually in the DLL. For Ada95 use the Import
pragma to inform the compiler that the procedure is external. For Modula-2 simply
allow the empty implementation module. You can suppress the warning generated
because a procedure was not implemented with the following directive <*/NOWARN:I*>.
The implementation of the module should have a LIBNEEDED
compiler directive. On Windows you reference the resolution LIB file. For
Unix systems you reference the shared object itself.
The procedures exported from the DLL are most likely using theoperating system standard calling convention, so interfacing should not pose anyspecial problems.
Use the following steps to use the DLL in your project(s).
- Add the interface file module source file to your project. This will automatically
add the necessary linker file to the project because of the LIBNEEDED directive.
- Access the DLL procedure(s) through the interface module.