Mysql – PERL+thesql: undefined symbol: thesql_init

dbiMySQLperl

I've updated mysql (client+server+dev) from the rpms available on mysql.com.

rpm -i MySQL-server-5.5.14-1.linux2.6.x86_64.rpm
rpm -i MySQL-client-5.5.14-1.linux2.6.x86_64.rpm
rpm -i MySQL-devel-5.5.14-1.linux2.6.x86_64.rpm

now, a script that used to connect to another server says:

perl: symbol lookup error: /usr/lib64/perl5/site_perl/5.8.8/x86_64-linux-thread-multi/auto/DBD/mysql/mysql.so: undefined symbol: mysql_init

the script:

use DBI;

$dsn="db";
$host="my.host.ip";
$user="anonymous"; 
$password="";
# Connect to the database.
 $dbh= DBI->connect("DBI:mysql:host=$host;database=$dsn",$user, $password,{'RaiseError' => 1});

So, I've reinstalled DBI-1.616 and DBD-mysql-4.019 from the sources. for DBD-mysql, Make test says:

$ make test
PERL_DL_NONLAZY=1 /usr/bin/perl "-MExtUtils::Command::MM" "-e" "test_harness(0, 'blib/lib', 'blib/arch')" t/*.t
t/00base....................ok 1/6                                           
#   Failed test 'use DBD::mysql;'
#   in t/00base.t at line 21.
#     Tried to use 'DBD::mysql'.
#     Error:  Can't load '/usr/local/package/DBD-mysql-4.019/blib/arch/auto/DBD/mysql/mysql.so' for module DBD::mysql: /usr/local/package/DBD-mysql-4.019/blib/arch/auto/DBD/mysql/mysql.so: undefined symbol: mysql_get_server_version at /usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi/DynaLoader.pm line 230.
#  at (eval 6) line 2
# Compilation failed in require at (eval 6) line 2.
# BEGIN failed--compilation aborted at t/00base.t line 21.
t/00base....................NOK 2FAILED--Further testing stopped: Unable to load DBD::mysql
make: *** [test_dynamic] Error 9

How can I fix this problem ?

Thanks !

Best Answer

OK, I've got the solution. As far as I understand, the mysql distribution I used is statically linked. So when DB:mysql is installed, it needs to be compiled with those static libraries:

  mkdir /tmp/mysql-static
  cp /usr/lib64/mysql/*.a /tmp/mysql-static
  perl Makefile.PL --libs="-L/tmp/mysql-static -lmysqlclient"
  make
  make test
  make install
  rm -rf /tmp/mysql-static
Related Topic