Compilation Flags
DB Link can be present in an application using two different protocols:
-
The target RDBMSs are known at compile-link time:
RDBMS-specific flags are used at compile time and the DB Link drivers corresponding to the target RDBMSs are linked to the application, together with the RDBMS client libraries.
-
The application is generic with respect to the RDBMSs:
No compile-time flag is used. The link-time options only refer to the DB Link driver manager library.
| Warning
Never mix both protocols in the same application, because linking with the driver manager is incompatible with “static” linkage of the drivers. |
When you use DB Link to write an application dedicated to a specific RDBMS, you must set some specific compiler flags. These flags depend on the target RDBMS and on the mode in which the code will be linked.
While reading the header files, DB Link defines other flags that you can use to achieve portability.
This section is divided as follows:
Compatibility with Previous Releases
Some changes in DB Link V5.x cause incompatibilities with code written for DB Link 4.x. The current version is not binary compatible with previous ones.
Generic Data Types
DB Link V5.x no longer defines its own basic data types (IldInt, IldShort, and so on). Instead, it uses the IFC (Views Foundation Classes) data types (IlInt, IlShort, and so on).
If you want to port an application that was developed with DB Link 4.x to DB Link V5.x, you need to make the changes listed in the following table.
Here is the list of changes to implement for the conversion:
|
Old Macro |
New Macro |
|
ILDWINDOWS |
WINDOWS |
|
ILDSTD |
|
|
ILDSTDUSE |
IL_STDUSE |
|
ILDSTDPREF |
IL_STDPREF |
|
ILD_MAX_NUM_LEN |
IL_MAX_NUM_LEN |
|
Old Data Type |
New Data Type |
|
IldBoolean |
IlBoolean |
|
IldFalse |
IlFalse |
|
IldTrue |
IlTrue |
|
IldInt |
IlInt |
|
IldUInt |
IlUInt |
|
IldAny |
IlAny |
|
IldUShort |
IlUShort |
|
IldByte |
IlUChar |
|
IldNumeric |
IlNumeric |
Library Organization
The organization of libraries has also changed.
-
With previous releases, there was one library for each supported database plus the library dblink to support dynamic loading.
-
This release contains:
A specific library that contains the DB Link kernel: dbkernel.
Plus one library for each supported RDBMS driver.
Plus two libraries defining whether RDBMS libraries are linked statically or dynamically: dblnkst and dblnkdyn.
So if you want your application to be linked statically with, for instance, IBM DB2 and Oracle 11 drivers, it must be linked with:
dblnkst + dbdb2 + dbora11 + dbkernel
If you want the application to use dynamically loadable drivers, it must be linked with:
dblnkdyn + dbkernel
Alternatively you can use the library dblinkdm instead of the above combination.
| Important!
With certain systems, the order of the libraries is important. You must use first the library that defines the link mode (static or dynamic), then, if used, the DB Link RDBMS driver, then finally the DB Link kernel. |
RDBMS Flags
There is one compiler flag for each supported RDBMS:
-
OLE-DB: ILDOLEDB
There must be at least one of these flags per compilation to allow the corresponding driver to be effectively linked at link time. If not, no error will be issued at compile time or at link time. At runtime, however, it will not be possible to create any connection.
The makefiles for all examples have a variable that defines one of these flags:
DBMSCCFLAGS=-DILDORACLE
Dynamic Load
DB Link is delivered as a set of libraries that include:
-
a kernel library: libdbkernel.a (or dbkernel.lib)
On PCs, there is no difference between a driver and the delivered DLL.
The kernel and dynamic load libraries ([lib]dbkernel, [lib]dblnkdyn, and [lib]dblinkdm) are themselves dynamically loadable on all UNIX® platforms.
On UNIX, the delivered shared libraries are not built as dynamically loadable drivers. On a per-platform basis, a makefile named Makefile.drv is delivered, which allows you to build the drivers using the delivered object files. You cannot build a driver unless you have installed the RDBMS client libraries in a version that includes shared libraries. Thus, if the target RDBMS is Informix, you need at least SDK version 3.5, and if the target is Oracle you need at least version 9.2. See Building Dynamically-Loadable Drivers under UNIX for more information.
| Warning
The only variables that can be modified in these makefiles are those regarding the list of RDBMS-dedicated libraries. The object files list must not be modified nor must the driver manager library be added to the library list. |
The drivers can be loaded only if their access path is present in an environment variable LD_LIBRARY_PATH.
Use of the dynamic load facility is demonstrated by a number of example files, which you can find in the directories examples/dblink/<port name>. The makefiles in these directories build the same examples as the ones that can be found in the dedicated directories. The makefiles in the dblink database differ from the others in that the DBMSCCFLAGS and DBMSLDFLAGS variable are empty, and the DBLIB variable is set to dblink.
Mode and Flag
DB Link is delivered as a set of libraries compiled in various compilation modes.
-
For UNIX®, there are two compilation modes per port: static_pic, and shared (and some variants like static_stl and shared_stl under AIX, and so on.) When your application is linked with the shared mode library, be sure you add the path to the library in the environment variable LD_LIBRARY_PATH before running it.






