Load DBLIB dynamically from your embedded SQL application using the esqldll.c module in the SDK\C subdirectory of your installation directory so that you do not need to link against the import library.
There are no prerequisites for this task.
Context and remarks
This task is an alternative to the usual technique of linking an application against a static import library for a Dynamic Link Library (DLL) that contains the required function definitions.
A similar task can be used to dynamically load DBLIB on Unix platforms.
Your application must call db_init_dll to load the DBLIB DLL, and must call db_fini_dll to free the DBLIB DLL. The db_init_dll call must be before any function in the database interface, and no function in the interface can be called after db_fini_dll.
You must still call the db_init and db_fini library functions.
You must include the esqldll.h header file before the EXEC SQL INCLUDE SQLCA statement or include sqlca.h in your embedded SQL program. The esqldll.h header file includes sqlca.h.
A SQL OS macro must be defined. The header file sqlos.h, which is included by sqlca.h, attempts to determine the appropriate macro and define it. However, certain combinations of platforms and compilers may cause this to fail. In this case, you must add a #define to the top of this file, or make the definition using a compiler option. The macro that must be defined for Windows is shown below.
|_SQL_OS_WINDOWS||All Windows operating systems|
Instead of linking against the import library, link the object module esqldll.obj with your embedded SQL application objects.
You can find a sample program illustrating how to load the interface library dynamically in the %SQLANYSAMP16%\SQLAnywhere\ESQLDynamicLoad directory. The source code is in sample.sqc.
The following example compiles and links sample.sqc with the code from esqldll.c on Windows.
sqlpp sample.sqc cl sample.c %SQLANY16%\sdk\c\esqldll.c /I%SQLANY16%\sdk\include Advapi32.lib
Discuss this page in DocCommentXchange.
|Copyright © 2014, SAP AG or an SAP affiliate company. - SAP Sybase SQL Anywhere 16.0|