DB connection library and dynamic linking



I am working on a piece of code that connects to two different Sybase databases. One connection is done directly in the code the other is done through an external library which I do not have control over, I just need to specify the database name and server in the second scenario.I am using Sybase Open Client library for both connection and it works fine.

I need to update the application which runs on a Solaris 8 machine to connect to a MSSQL server instead of Sybase and I have chosen FreeTDS for that scenario.
An earlier trial using Sybase ct-lib to connect to MSSQL failed, eventhough the TDS version is set to 4.2. FreeTDS contains also a ct-lib implementation.

Since both the FreeTDS library and Sybase Open Client library has a ct-lib implementation. I am facing problem of forcing the application to use the "right" library for connection. What I need is following scenario

FreeTDS (I have the soruce code) -> MSSQL DB connection
Sybase Open Client (external library) -> Sybase DB connection

Is there any way to force to code, compile or link application to choose a specific library in the code.




Is there any way to force to code, compile or link application to choose a specific library in the code.


I dunno about linking but for compiling we can use the conditional directives #ifdef <macro> aka conditional compilation.

#ifdef MSSQL
<all the code for MSSQL>
#endif

#ifdef Sybase
<all the code for Sybase>
#endif

During compilation for the program you usually pass in a flag say -DMSSQL or -DSybase and the C++ compiler will do conditional compilation based on the macro defined as you stated.

Please note you need to check the option as I uses g++ the option is -D<macro name>

PS This is the same way -DDEBUG or -D__DEBUG__ etc etc pattern is used in many libraries. They will provide a debug-library build and then the production-library build. When using commercial libraries, try not to clash else you see their debugging info and your own program debugging info flooding your screen!!!
need to update the application which runs on a Solaris 8 machine to connect to a MSSQL server instead
You have your work cut out for you. Apparently the FreeTDS ODBC driver ought to be what you use.

This wrapper might help, it's not free (but not expensive). http://www.sqlapi.com/
Topic archived. No new replies allowed.