|
A DLL is a collection of functions and resources that can be shared by applications. It is similar to a runtime library in that it stores functions that many applications need. It differs, however, from a runtime library in the way that it is linked to the calling application.
Libraries that are linked at compile time are static-link libraries. The libraries such as libc and libcmt (used with the Microsoft Visual C++, Version 2.x) are static-link libraries. Whenever you link one of these Microsoft Visual C++ (Version 2.x) libraries to your application, the linker copies the code from the appropriate static-link library to the executable file (.exe) for your application. By contrast, when you link dynamically, no code is copied to the executable file of your application. Instead, your functions are linked at runtime.
Static-link libraries are effective in an environment where no multitasking is required. However, they become inefficient when more than one application calls the same functions. For example, if two applications that are running simultaneously in a Windows environment call the same static-link function, two copies of the function reside in memory. This situation is inefficient.
But if a function is dynamically linked, Windows NT and Windows 95 first checks memory to see if a copy of the function already resides there. If a copy exists, the Windows system uses that copy rather than making another copy. If the function does not yet exist in memory, the Windows system links or copies the function into memory from the DLL.
The ESQL/C library functions, as well as other internal functions, are contained in the ESQL client-interface DLL. To use these functions in your ESQL/C application, you must perform the following tasks:
To enable your ESQL/C application to access the ESQL client-interface DLL, Informix provides the import library of the DLL. The linker uses an import library to locate functions that are contained in the DLL. It contains references that reconcile function names used in an application with the library module that contains the function.
When you link a static library to your application, the linker copies program code from your static-link libraries to the executable file. However, if you link an import library to your application, the linker does not copy the program code when it links the executable file. Instead, the linker stores the information needed to locate the functions in the DLL. When you run your application, this location information serves as a dynamic link to the DLL.
The ESQL client-interface library provides location information for the ESQL/C function calls. The esql command processor automatically links the import and Windows libraries for the DLL whenever you use it to compile and link your ESQL/C program.
During the development of your application, the ESQL/C software (such as the esql command processor) must be able to access object libraries and import libraries. However, DLLs must be accessible when the application is running. Consequently, Windows must be able to locate them on your hard disk.
Windows NT and Windows 95 search directories for your DLL in the following order:



You can tell the ESQL/C processor to build an ESQL/C program as a DLL (.dll file) with the -target (or -wd) command-line option. Such an ESQL/C program is called an application DLL.
To build an ESQL/C program as a DLL, follow the guidelines for general-purpose DLLs. For more information, refer to your system documentation. Compile the ESQL/C source file with the -target:dll (or -wd) to create the application DLL.
For an example of how to build an application DLL, see the WDEMO demo program in the %INFORMIXDIR%\demo\wdemo directory. The ESQL/C source file for the sample application DLL is called wdll.ec. To compile this DLL, use the following esql command:
The source code for the WDEMO executable file is in the wdemo.exe file.