Using Ubuntu, how do I install DBD::Sybase from CPAN?

dbd, freetds, perl, sql-server, sybase

Solution

There are two ways to do that,

- (a) with the freetds that the distro provides

- or, (b) installing the vanilla freetds upstream and building against that.

The second option (b) is always possible, but then your system may have two different versions of freetds.

The first option can not be done without some hacking and the author will not fix it. He is simply hard headed and wants to fix internal structures to match the OS he uses rather than making it accepting of other configurations.

Internally `DBD::Sybase` expects there to be a directory, and a `$libdir` (a subdirectory with `lib` or `lib64`). The directories `DBD::Sybase` requires to build properly are not provided by the Debian package `freetds-dev`; the Debian package installs to `/usr/include` which doesn't have a `lib` or a `lib64` subdirectory. You can get around this by fooling `make` and recreating that structure, first make sure you have `freetds-dev` installed,

sudo apt-get install freetds-dev

Then link it to create a pseudo-package. On my 64 bit machine, it looks something like this.

mkdir /tmp/freetds
ln -s /usr/lib/x86_64-linux-gnu/ /tmp/freetds/lib64
ln -s /usr/include /tmp/freetds/include/freetds

Now, it should work and you can build `DBD::Sybase` against system libraries.

sudo SYBASE=/tmp/freetds cpanp install DBD::Sybase

Viola.

Problem

Whenever I try to build `DBD::Sybase` to connect to MSSQL I get an error, ``` $ sudo cpanp install DBD::Sybase Installing DBD::Sybase (1.15) Running [/usr/bin/perl /usr/bin/cpanp-run-perl /home/ecarroll/.cpanplus/5.14.2/build/DBD-Sybase-1.15/Makefile.PL INSTALLDIRS=site]... Can't find any Sybase libraries in /etc/lib or /etc/lib64 at /home/ecarroll/.cpanplus/5.14.2/build/DBD-Sybase-1.15/Makefile.PL line 155, <IN> line 44. BEGIN failed--compilation aborted at /usr/bin/cpanp-run-perl line 11, <IN> line 44. [ERROR] Could not run '/usr/bin/perl Makefile.PL': Can't find any Sybase libraries in /etc/lib or /etc/lib64 at /home/ecarroll/.cpanplus/5.14.2/build/DBD-Sybase-1.15/Makefile.PL line 155, <IN> line 44. BEGIN failed--compilation aborted at /usr/bin/cpanp-run-perl line 11, <IN> line 44. -- cannot continue [ERROR] Unable to create a new distribution object for 'DBD::Sybase' -- cannot continue *** Install log written to: /home/ecarroll/.cpanplus/install-logs/DBD-Sybase-1.15-1374605483.log Error installing 'DBD::Sybase' Problem installing one or more modules ``` I've also gotten this error on other Debian systems.

Original source