http://qs321.pair.com?node_id=877543

Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

I have a few perl programs which use Sybase::DBlib and Sybase::CTlib to connecto to Sybase 12.5 databases. The Sybase databases have been migrated to SQL Server 2008(R2), so I have to change the perl programs to connect to the SQL Server databases.

I'm trying to use FreeTDS to do that as it supports TDS protocol 8 (which is same as the one used by SQL Server). I have got FreeTDS installed (as mentioned by this node in perlmonks: http://www.perlmonks.org/?node_id=392385) and made required changes to the freetds.conf. This node also mentions compiling of DBD::Sybase after exporting the LD_LIBRARY_PATH and SYBASE to the freetds installation paths.

Since I already have Sybase::CTlib and Sybase::CTlib installed, should I recompile them after exporting the LD_LIBRARY_PATH and SYBASE to point to freetds paths? (Posted the same question on the above node too, sorry for the double post)

Another question: The perl libraries are compiled as 32 bit and FreeTDS libraries are compiled as 64 bit. Will this be an issue? For example this is what I see when I run a 'file' command on:

$ file /opt/perl-5.6.1/lib/site_perl/5.6.1/i686-linux/auto/Sybase/DBli +b/DBlib.so /opt/perl-5.6.1/lib/site_perl/5.6.1/i686-linux/auto/Sybase/DBlib/DBlib +.so: ELF 32-bit LSB shared object, Intel 80386, version 1 (SYSV), not + stripped
and
$ file /opt/sqlserver/client/freetds/0.82-1/lib/libsybdb.so.5.0.0 /opt/sqlserver/client/freetds/0.82-1/lib/libsybdb.so.5.0.0: ELF 64-bit + LSB shared object, AMD x86-64, version 1 (SYSV), not stripped

Some other details - freetds version: 0.82-1, perl version: 5.6.1, SQL Server: 2008 R2, OS: Linux 2.6

Replies are listed 'Best First'.
Re: Accessing sql server from perl using dblib/ctlib and freetds
by Anonyrnous Monk (Hermit) on Dec 16, 2010 at 20:47 UTC
    The perl libraries are compiled as 32 bit and FreeTDS libraries are compiled as 64 bit. Will this be an issue?

    Yes, this will be an issue. as you can't mix 32- and 64-bit code in one program.

    In other words, the executable (perl) and the libraries it uses (such as DBlib.so with its dependencies libsybdb.so.5.0.0, etc.) all need to be either 32-bit or 64-bit.

    So, as you have a 32-bit perl (rather ancient, btw), you'd have to rebuild the FreeTDS libs as 32-bit.  The other option would be to build a new 64-bit perl (plus Sybase::DBlib and Sybase::CTlib), so you can link against the already existing 64-bit libsybdb.so.

      Thanks a lot Anonyrnous Monk.
Re: Accessing sql server from perl using dblib/ctlib and freetds
by Anonymous Monk on Dec 20, 2010 at 15:18 UTC

    Could someone please suggest if the recompile of Sybase::DBlib and Sybase::CTlib is required after installation of FreeTDS? This is to ensure that the DBlib and CTlib are pointing to FreeTDS libs instead of Sybase libs.

    I'm thinking it is required because Sybase::DBlib and Sybase::CTlib pre-installation instructions says that the SYBASE path need to be exported. Is this reasoning correct?

      Most likely, yes, you'll need to recompile them. There's a remote chance it might not be required — this would be under the following circumstances:

      • the FreeTDS libs are 100% interface (API) and binary (ABI) compatible with the Sybase libs, i.e. a drop-in replacement (not sure if this is the case)
      • the new libs are actually found at runtime (e.g. via appropriate LD_LIBRARY_PATH settings)

      You can always check with ldd which dependent libraries are being pulled in (if any) by your old DBlib.so and CTlib.so. Make sure you call it from within the right environment.

        Thanks again Anonyrnous Monk. Yes, I ended up recompiling the DBlib.so and CTlib.so. The 'ldd' showed that it was pointing to the Sybase libs
      Yes, recompilation is necessary - because although FreeTDS tries to be binary compatible with Sybase OpenClient they aren't there 100%.

      Michael