When running a Perl script using DBD::ODBC linked with the unixODBC Driver Manager, if you get:
DBI->connect(test) failed: (Unable to fetch information about the error) (DBD: dbd_db_login/SQLSetConnectOption err=-2) at perl_e1.pl line 9
the cause may be the combination of lazy linking and RTLD_GROUP
.
Did make test
succeed when building DBD::ODBC? make test
sets PERL_DL_NONLAZY
to 1
. If lazy linking is the problem, it won't be uncovered by make test
.
Try running your Perl script again with the environment variable PERL_DL_NONLAZY
set to 1
.
If this solves the problem, you probably have a unixODBC Driver Manager that sets the RTLD_GROUP
flag to dlopen
.
If you're using the unixODBC Driver Manager distributed with the Easysoft ODBC-ODBC Bridge, please let us know the name of your ODBC-ODBC Bridge distribution file. If you're using unixODBC 2.2.6 or later, you can rebuild unixODBC with the configure
option --enable-rtldgroup=no
. If you are using unixODBC 2.2.5 or earlier, you need to stop unixODBC using the RTLD_GROUP
flag in libltdl/ltdl.c.
Edit libltdl/ltdl.c
in the unixODBC source tree, search for a dlopen
call using RTLD_GLOBAL
(which is ORed
with LT_LAZY_OR_NOW
). Delete LT_GLOBAL |;
. For example:
lt_module module = dlopen (filename, LT_GLOBAL | LT_LAZY_OR_NOW);
becomes:
lt_module module = dlopen (filename, LT_LAZY_OR_NOW);
mod_perl
Try adding:
SetEnv PERL_DL_NONLAZY 1
to the httpd.conf
file and restart Apache. Then follow instructions in the previous bullet point.
mod_perl
under Apache:
Set the environment variable PERL_DL_NONLAZY
to 1
, export it, and then restart Apache.
If this solves the problem, you need to set and export PERL_DL_NONLAZY
in your apachectl
startup program.
If this doesn't solve the problem and you're using a unixODBC Driver Manager newer than 2.2.6, rebuild unixODBC with the configure
option --enable-rtldgroup=no
.
Easysoft build the unixODBC Driver Manager with the following configure
options:
./configure --prefix=/usr/local/easysoft/unixODBC --sysconfdir=/etc --enable-threads=no (or yes when building a thread-safe version) --enable-iconv=no --enable-drivers=no --enable-gui=yes (or no if you don't have X and QT)
To dlopen
unixODBC in an application, --enable-rtldgroup=yes
needs to be added to the unixODBC 2.2.6, 2.2.7, 2.2.8+ configure line.
We also use --enable-readline=no
on some platforms, because many newer machines don't have the libreadline
version that's present on our build machines (which are older, for backwards compatibility reasons).