freetds AT lists.ibiblio.org
Subject: FreeTDS Development Group
List archive
Re: [freetds] Has anyone integrate Sybase Library with FreeTDS library
- From: Michael Peppler <mpeppler AT peppler.org>
- To: FreeTDS Development Group <freetds AT lists.ibiblio.org>
- Subject: Re: [freetds] Has anyone integrate Sybase Library with FreeTDS library
- Date: Wed, 07 Nov 2007 20:36:31 +0100
James K. Lowden wrote:
Fu, Steve wrote:
I need to access Sybase and MSSQL servers from the same C++ program and
I Prefer to use Syabse CT lib to access Sybase and FreeTDS lib to access
MSSQL serever.
I cannot link libdb.a from both Sybase and FreeTDS? Are there any
suggestions or pointers?
I don't see any easy way to do this, Steve. It's not a problem unique to
you; there are people who'd like to use DBD::Sybase (a C ct-lib module)
with the same discriminate-by-server feature.
The first problem, as you know, is that FreeTDS *intentionally* produces
symbols that match Sybase's. The second problem is that the header files,
while similar, aren't interchangeable.
The C approach would be to change all the symbols at the source. Something like:
#if FREETDS_IS_FREETDS
#define ct_connect ct_connect_via_freetds
#endif
There are 90 functions that would need that treatment. Then you could
obviously link to both libraries (because you'd have new symbols). Your
application would then need a giant switch statement to choose the right
version at runtime.
An admin approach is to build FreeTDS as is, and use dlopen(3) to load
only one library at a time. But you could use only one library at a time.
Actually that's not quite the case.
I have a perl module calld DBD::FreeTDS which links the freetds version of the open client libs, and I can load it in perl at the same time as I have DBD::Sybase (with Sybase open client) loaded.
The trick is to build a shared object that includes the functionality that is needed, and which links to the appropriate version of the API libraries (freetds or sybase), and then load this shared object to the main program via dlopen(). You need to make sure that you load without sharing the symbols between the two shared object modules (I forget the exact flag, the man page for dlopen() should mention it).
It's not really pretty, but it works quite well.
Michael
--
Michael Peppler - Peppler Consulting SaRL
mpeppler AT peppler.org - http://www.peppler.org
Sybase DBA/Developer - TeamSybase: http://www.teamsybase.com
Sybase on Linux FAQ - http://www.peppler.org/FAQ/linux.html
-
[freetds] Has anyone integrate Sybase Library with FreeTDS library,
Fu, Steve, 11/06/2007
-
Re: [freetds] Has anyone integrate Sybase Library with FreeTDS library,
James K. Lowden, 11/06/2007
-
Re: [freetds] Has anyone integrate Sybase Library with FreeTDS library,
Fu, Steve, 11/07/2007
- Re: [freetds] Has anyone integrate Sybase Library with FreeTDS library, James K. Lowden, 11/07/2007
- Re: [freetds] Has anyone integrate Sybase Library with FreeTDS library, Michael Peppler, 11/07/2007
-
Re: [freetds] Has anyone integrate Sybase Library with FreeTDS library,
Fu, Steve, 11/07/2007
-
Re: [freetds] Has anyone integrate Sybase Library with FreeTDS library,
James K. Lowden, 11/06/2007
Archive powered by MHonArc 2.6.24.