Why do I get "SQLSetConnectOption err=-2" errors in my Perl scripts

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.

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).