freetds AT lists.ibiblio.org
Subject: FreeTDS Development Group
List archive
Re: [freetds] Has anyone integrate Sybase Library with FreeTDS library
- From: "James K. Lowden" <jklowden AT freetds.org>
- To: FreeTDS Development Group <freetds AT lists.ibiblio.org>
- Subject: Re: [freetds] Has anyone integrate Sybase Library with FreeTDS library
- Date: Tue, 6 Nov 2007 18:15:33 -0500
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.
The C++ approach would be to put the FreeTDS functions in their own
namespace, converting them to C++ linkage at the same time. Then you
could overload the functions in the primary namespace by, say, redefining
the connection handle type e.g.:
CS_RETCODE ct_connect( TDS_CONNECTION * con,
CS_CHAR * servername,
CS_INT snamelen)
{
return freetds::ct_connect( con,
servername,
snamelen );
}
As I said, no easy way. But there are ways. Maybe the best one is to
keep improving FreeTDS to the point that other implementations aren't
worth the bother.
HTH.
--jkl
-
[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.