When running a Perl script using DBD::ODBC linked with the unixODBC Driver Manager, you see something similar to this:
DBI->connect(test) failed: (Unable to fetch information about the error) (DBD: dbd_db_login/SQLSetConnectOption err=-2) at perl_e1.pl line 9
We believe this is caused by the combination of lazy linking and RTLD_GROUP.
Did the make test work when building DBD::ODBC? The DBD::ODBC make test sets PERL_DL_NONLAZY to 1. If LAZY linking is the problem, you don't see it in the DBD::ODBC test, but can see it later when running your own scripts.
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 are 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 are 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, look for a dlopen
call using RTLD_GLOBAL (which is ORed
with LT_LAZY_OR_NOW
). Delete "LT_GLOBAL |;
". E.g.:
lt_module module = dlopen (filename, LT_GLOBAL | LT_LAZY_OR_NOW);
becomes:
lt_module module = dlopen (filename, LT_LAZY_OR_NOW);
Try adding:
SetEnv PERL_DL_NONLAZY 1
to the httpd.conf file and restart Apache. Then follow instructions under the previous bullet point.
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 does not solve the problem and you are using a unixODBC Driver Manager newer than 2.2.6, you need to 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).