INFORMIX
Informix-ESQL/C Programmer's Manual
Chapter 13: Using Informix Libraries
Home Contents Index Master Index New Book

Choosing a Version of the Informix General Libraries

This section provides information on the following topics:

The Informix General Libraries

UNIX
The following table lists the Informix general libraries for ESQL/C on a UNIX platform.
Informix General Library Purpose

libgen

Contains functions for general tasks

libos

Contains functions for tasks that are required from the operating system

libsql

Contains functions that send SQL statements between client application and database server

libgls

Contains functions that provide Global Language Support (GLS) to Informix products

libasf

Contains functions that handle communication protocols between client application and database server

Informix general libraries reside in the $INFORMIXDIR/lib/esql and $INFORMIXDIR/lib directories on UNIX operating systems.

Windows
The Informix general library for ESQL/C for Windows is just one DLL named isqlt09a.dll. It resides in the %INFORMIXDIR%\lib directories in Windows environments.

The esql Command

To determine which type of Informix general libraries to link with your ESQL/C application, the esql command supports the command-line options in Figure 13-2.

Figure 13-2
esql Command-Line Options for Informix General Libraries

Version of Informix
Libraries to Link
esql Command-
Line Option
Reference and Comments

Shared libraries

No option (default)

"Linking Shared Informix General Libraries"

Static libraries

-static
UNIX

"Linking Static Informix General Libraries". This option available for UNIX operating systems only.

Thread-safe shared libraries

-thread
UNIX

"Linking Thread-Safe Informix General Libraries to an ESQL/C Module on a UNIX Operating System" and "Linking Thread-Safe Informix General Libraries to an ESQL/C Module in a Windows Environment"

Thread-safe static libraries

-thread -static
UNIX

"Creating a Dynamic Thread Library on UNIX Operating Systems"

For the complete syntax of the esql command, see "Using the esql Command".

UNIX

Linking Static Informix General Libraries

The static Informix general libraries retain their pre-Version 7.2 names. Static-library names have the following formats:

In these static-library names, xxx identifies the particular static Informix general library. With Version 7.2 and later, the static and thread-safe static Informix general libraries use names of this format as their actual names. The following sample output shows the actual names for the libos static (libos.a) and thread-safe static (libthos.a) libraries:

The esql command links the code that is associated with the actual names of the static Informix general libraries into the ESQL/C application. At runtime, your ESQL/C program can access these Informix general-library functions directly from its executable file.

Linking Static Informix General Libraries into an ESQL/C Module

To link static Informix general libraries with an ESQL/C module, compile your program with the -static command-line option. The following command links the static non-thread-safe Informix libraries with the file.exe executable file:

The esql command can also link the code for thread-safe shared Informix general libraries with an ESQL/C application. For more information, see "Linking Thread-Safe Libraries".

Tip: The esql command for pre-Version 7.2 ESQL/C products linked static versions of the Informix general libraries. Because the esql command links shared versions of these libraries by default, you must specify the -static option to link the static versions with your ESQL/C application.

Linking Shared Informix General Libraries

ESQL/C can dynamically link a shared library, which places this library in shared memory. Once the shared library is in shared memory, other ESQL/C applications can also use it. Shared libraries are most useful in multiuser environments where only one copy of the library is required for all applications.

Important: To use shared libraries in your ESQL/C application, your operating system must support shared libraries. Operating systems that support shared libraries include Sun and HP versions of UNIX as well as Windows NT and Windows 95. You should be familiar with the creation of shared libraries and with the compile options that your C compiler requires to build them.
UNIX

Symbolic Names of Linked Shared Libraries

When the esql command links shared or thread-safe shared Informix libraries with your ESQL/C application, it uses the symbolic names of these libraries. The symbolic names of the Informix shared libraries have the following formats:

In these static-library names, xxx identifies the particular library and yyy is a platform-specific file extension that identifies shared library files.

Tip: To refer to a specific shared-library file, this manual often uses the file extension for the Sun UNIX operating system, the .so file extension. For the shared-library file extension that your UNIX operating system uses, refer to your UNIX operating system documentation.
When you install the ESQL/C product, the installation script makes a symbolic link of the actual shared library name to the file with the symbolic name. Figure 13-3 shows the format for the actual names of shared and thread-safe shared versions of Informix libraries.

Figure 13-3
Format of an Informix
Shared-Library Name

The following sample output shows the symbolic and actual names for the libos.a static library and the libos.so shared library (on a Sun platform):

The esql command links the symbolic shared-library names with the ESQL/C application. At runtime, ESQL/C dynamically links the code for the shared Informix general library when the program requires an Informix general-library function.

To link shared Informix general libraries into an ESQL/C module

1. Set the environment variable that specifies the library search path at runtime so that it includes the $INFORMIXDIR/lib and $INFORMIXDIR/lib/esql paths on a UNIX operating system; and %INFORMIXDIR%\xf5 ib in a Windows environment.

setenv LD_LIBRARY_PATH $INFORMIXDIR/lib:$INFORMIXDIR/ lib/esql:/usr/lib

set LIB = %INFORMIXDIR%\lib\;%LIB%

    2. Compile your program with the esql command.

    To link shared Informix general libraries with an ESQL/C module, you do not need to specify a command-line option. ESQL/C links shared libraries by default. The following command compiles the file.ec source file with shared Informix libraries:

esql file.ec -o file.exe

The esql command also uses the symbolic name when it links the thread-safe shared Informix general libraries with an ESQL/C application. For more information, see "Linking Thread-Safe Libraries".

UNIX

Choosing Between Shared and Static Versions

Pre-Version 7.2 ESQL/C products use static versions of the libraries for the Informix general libraries. While static libraries are effective in an environment that does not require multitasking, they become inefficient when more than one application calls the same functions. Version 7.2 and later of ESQL/C also supports shared versions of the Informix general libraries.

Shared libraries are most useful in multiuser environments where only one copy of the library is required for all applications. Shared libraries bring the following benefits to your ESQL/C application:

Although shared libraries save both disk and memory space, when an ESQL/C application uses them it must perform the following overhead tasks:

These overhead tasks can incur runtime penalties and are not necessary when you use static libraries. However, these costs can be offset by the savings in input/output (I/O) access time once the operating system has already loaded and mapped an Informix shared library.

Important: You might experience a one-time negative effect on the performance of the client side of the application when you load the shared libraries the first time the application is executed. For more information, consult your operating system documentation.
Because the real I/O time that the operating system needs to load a program and its libraries usually does not exceed the I/O time saved, the apparent performance of a program that uses shared libraries is as good as or better than one that uses static libraries. However, if applications do not share, or if your CPU is saturated when your applications call shared-library routines, you might not realize these savings.

UNIX
You can also link thread-safe versions of the static and shared Informix general libraries with an ESQL/C application. For more information, see
"Creating a Dynamic Thread Library on UNIX Operating Systems".




Informix-ESQL/C Programmer's Manual, version 9.1
Copyright © 1998, Informix Software, Inc. All rights reserved.