artperl has asked for the wisdom of the Perl Monks concerning the following question:

hi, im trying to run a script on a system but getting below error. i confirmed my script is working as i ran it on another system with success. i tried to compare the 2 systems with all the linkings etc but can't find any diff. appreciate your advise how to fix this. Can't load '/usr/local/lib64/perl5/auto/DBD/mysql/mysql.so' for module DBD::mysql: libmysqlclient.so.18: cannot open shared object file: No such file or directory at /usr/lib64/perl5/DynaLoader.pm line 200.

Replies are listed 'Best First'.
Re: cannot open shared object file
by vinoth.ree (Monsignor) on Apr 15, 2015 at 12:16 UTC
    Hi,

    Try force reinstall these two modules in the system where are getting this error message. DBI, DBD::mysql

    KNOWN PROBLEMS

    1)If Perl was compiled with gcc or egcs, but MySQL was compiled with another compiler or on another system, an error message like this is very likely when running ``Make test'':   t/00base............install_driver(mysql) failed: Can't load
      '../blib/arch/auto/DBD/mysql/mysql.so' for module DBD::mysql:
      ../blib/arch/auto/DBD/mysql/mysql.so: undefined symbol: _umoddi3
      at /usr/local/perl-5.005/lib/5.005/i586-linux-thread/DynaLoader.pm
      line 168.
    
    This means, that your linker doesn't include libgcc.a. You have the following options:
    
    The solution is telling the linker to use libgcc. Run
      gcc --print-libgcc-file
    
    to determine the exact location of libgcc.a or for older versions of gcc
      gcc -v
    
    to determine the directory. If you know the directory, add a
      -L<directory> -lgcc
    
    
    2)There are known problems with shared versions of libmysqlclient, at least on some Linux boxes. If you receive an error message similar to   install_driver(mysql) failed: Can't load
      '/usr/lib/perl5/site_perl/i586-linux/auto/DBD/mysql/mysql.so'
      for module DBD::mysql: File not found at
      /usr/lib/perl5/i586-linux/5.00404/DynaLoader.pm line 166
    
    then this error message can be misleading: It's not mysql.so that fails being loaded, but libmysqlclient.so! The usual problem is that this file is located in a directory like
      /usr/lib/mysql
    
    where the linker doesn't look for it.
    
    The best workaround is using a statically linked mysqlclient library, for example
      /usr/lib/mysql/libmysqlclient.a
    
    You force linking against this file by replacing
      -L/usr/lib/mysql -lmysqlclient
    
    with
      /usr/lib/mysql/libmysqlclient.a
    
    

    All is well. I learn by answering your questions...
      thanks for the inputs. i actually did force the installation of the required modules on the system with issue, & that is how I got the error message when running the script. Can you pleas guide me how I do the linking? which path & syntax to add the linking? thanks much!...

        Find the KNOWN PROBLEMS

        This link has the "Configuration" & "Linker flags". links read those will helpful.


        All is well. I learn by answering your questions...
Re: cannot open shared object file
by ww (Archbishop) on Apr 15, 2015 at 12:06 UTC
    • mysql.so not found (ie, module not installed on system which fails) possibly because...
      • failing system lacks appropriate compiler
      • or, more likely IMO, failing system lacks libmysqlclient.so

    A quick and dirty check: use perldoc modulename to check existance.

Re: cannot open shared object file
by locked_user sundialsvc4 (Abbot) on Apr 15, 2015 at 17:23 UTC

    If this is a Linux system, here are a couple of more things to try:

    (1)   “Trust, but verify™” that the libraries aforementioned are actually there, and that they are recently-created.   That there are no other copies.   That every apparently-related library is equally up-to-date.

    (2)   Be sure that the location where these libraries are found, is in fact the right one.   That they could and would be found there.

    (3) Maybe root needs to execute the command /sbin/ldconfig.   Linux uses a “loader cache” instead of an actual directory-search to find things.   Installers usually execute that command, but maybe it wasn’t.   If the cache is stale, the file won’t be found, even if it is there.