Why does RWDBManager::database need shared library name?

499 views Asked by At

I am using Roguewave library to connect to Sybase database from C++. I understand that database object is constructed as:

  RWDBManager::database("accessLib", "", "", "", "", "XA=lrm_name");

http://www2.roguewave.com/support/docs/sourcepro/edition8/html/dbxaug/5-3.html says

All arguments are of type RWCString. Note that establishing an XA connection to the Sybase CT database requires only two of the six database() arguments, as described here:

  accessLib

  The argument for the first parameter is the same as that which you provide for the non-XA connection.

  For static libraries, supply the string "SYBASE_CT".

  For shared libraries, supply the name of your shared access library, for example "libctl420d.so". 

I don't understand:

In the code, I am used to seeing that when we have to use something provided in a library, include headers of that libraries, use classes/functions from this libraries and then while compiling your project use this library in LDLIBRARIES list. Why does the function database here needs the NAME of library? What are the advantages of this approach as against to #include approach.

Is it some standard technique? Usually where is this used? I have worked on projects which used shared libraries and so linking was not done statically, but I haven't encountered such thing.

Thanks,

1

There are 1 answers

4
neuro On BEST ANSWER

It is probably because they dynamically load the library using it's name and a standard call like dlopen() on POSIX systems. There is an equivalent in windows, I think it is LoadLibrary(). With such a system you are able to load a library and get symbols from it. Very convenient to build plugin systems or things like that. It also allows you to use some performance enhancing libraries only if they are present ...

See here for example ...

my2c

EDIT:

As why they choose this design, besides asking them, you have to guess :)

My guess : easier to maintain DB drivers in a plugin architecture : easier to install, switch between versions, easier to deliver binary patch ...

Another guess : the only way to implement some sort of introspection / reflection.