Bug #19348 Can't load 'mysql.so' for module DBD::mysql:
Submitted: 25 Apr 2006 18:49 Modified: 12 May 2006 9:56
Reporter: Andy Chen Email Updates:
Status: Closed Impact on me:
None 
Category:Connectors: DBD::mysql ( Perl ) Severity:S1 (Critical)
Version:3.0002 OS:Solaris (Solaris 10 SPARC)
Assigned to: CPU Architecture:Any

[25 Apr 2006 18:49] Andy Chen
Description:
Using Apps:
GCC 3.3.2
Perl 5.8.7
Mysql 5.1.7b

Platform: Sun E250

OS: Solaris 10 U1 with newest patches set

Made change in Makefile to get GCC works:
35c35
< CC = gcc -B/usr/ccs/bin/
---
> CC = gcc
40c40
< LD = gcc -B/usr/ccs/bin/
---
> LD = gcc
150c150
< INC = -I$(DBI_INSTARCH_DIR) -I/usr/local/mysql/include  -mt -D_FORTEC_ -xarch=v9 -xc99=none -DDBD_MYSQL_INSERT_ID_IS_GOOD -g
---
> INC = -I$(DBI_INSTARCH_DIR) -I/usr/local/mysql/include  -D_FORTEC_ -DDBD_MYSQL_INSERT_ID_IS_GOOD -g
299c299
< EXTRALIBS = -L/usr/local/mysql/lib -lmysqlclient -lz -lposix4 -lcrypt -lgen -lmtmalloc
---
> EXTRALIBS = -L/usr/local/mysql/lib -lmysqlclient -lnsl -lm -lz -lposix4 -lcrypt -lgen -lmtmalloc
302a303
> LD_PRELOAD = /usr/lib/libmtmalloc.so

couldn't pass the make test, and got those error messages from screen:
......................
Can't locate object method "connect" via package "Mysql" at /export/perl_DB/DBD-mysql-3.0002/blib/lib/Mysql.pm line 71.
t/mysql2.............dubious
        Test returned status 2 (wstat 512, 0x200)
Failed Test         Stat Wstat Total Fail  Failed  List of Failed
-------------------------------------------------------------------------------
t/00base.t             2   512     5    4  80.00%  4-5
t/10dsnlist.t          2   512     9   18 200.00%  1-9
t/20createdrop.t       2   512     5   10 200.00%  1-5
t/30insertfetch.t      2   512    11   22 200.00%  1-11
t/35limit.t            2   512   113  226 200.00%  1-113
t/40bindparam.t        2   512    27   54 200.00%  1-27
t/40blobs.t            2   512    11   22 200.00%  1-11
t/40listfields.t       2   512    18   36 200.00%  1-18
t/40nulls.t            2   512    11   22 200.00%  1-11
t/40numrows.t          2   512    25   50 200.00%  1-25
t/41blobs_prepare.t    2   512    24   48 200.00%  1-24
t/50chopblanks.t       2   512    35   70 200.00%  1-35
t/50commit.t           2   512    30   60 200.00%  1-30
t/ak-dbd.t             2   512    90  180 200.00%  1-90
t/akmisc.t             2   512   351  702 200.00%  1-351
t/dbdadmin.t           2   512    21   42 200.00%  1-21
t/insertid.t           2   512    12   24 200.00%  1-12
t/mysql.t              2   512    68  136 200.00%  1-68
t/mysql2.t             2   512    ??   ??       %  ??
1 test skipped.
Failed 19/20 test scripts, 5.00% okay. 863/866 subtests failed, 0.35% okay.
make: *** [test_dynamic] Error 2

Tried run the test perl script:
#!/usr/local/bin/perl

use DBI;
use User::pwent;
use Time::Local ;

exit 0

Also got error messages:
install_driver(mysql) failed: Can't load '/usr/local/lib/perl5/site_perl/5.8.7/sun4-solaris/auto/DBD/mysql/mysql.so' for module DBD::mysql: ld.so.1: perl: fatal: libmtmalloc.so.1: DF_1_NOOPEN tagged object may not be dlopen()'ed at /usr/local/lib/perl5/5.8.7/sun4-solaris/DynaLoader.pm line 230.
 at (eval 5) line 3
Compilation failed in require at (eval 5) line 3.
Perhaps a required shared library or dll isn't installed where expected
 at /dev/test_DB_connect line 8

How to repeat:
1. Download GCC 3.3.2 and Perl 5.8.7 for Solaris 10 from www.sunfreeware.com, Mysql 5.1.7beta from www.MySQL.com
2. Download DBI-1.50.tar from CPAN and compile it with changed in Makefile:
34c34
< CC = gcc -B/usr/ccs/bin/
---
> CC = gcc
39c39
< LD = gcc -B/usr/ccs/bin/
---
> LD = gcc
3. run "make", "make test", and "make install" for the DBI module.
4. Download DBD-mysql-3.0002.tar from CPAN and compile it with changed in Makefile mentioned above.
[26 Apr 2006 8:40] Valeriy Kravchuk
Thank you for a problem report. How did you install MySQL 5.1.7b? Please, send the ./configure command line if you compiled it yourself.

What is the value of LD_LIBRARY_PATH environment variable?

Finally, please, try to repeat with newer version of MySQL server, 5.1.9b, and inform about the results.
[26 Apr 2006 14:29] Andy Chen
Thanks for quick reply. I download the MySQL 5.1.7b 64bit tar format for Solaris 10, and direct untar it to /usr/local. The my.cnf didn't create yet, so I assume the MySQL is using default configurations.

After opened this case, I also tried older versions (5.0.12 64bit, 5.0.20 23bit) but still have same problem, looks like it's DBD::mysql's issue to me...
[26 Apr 2006 14:32] Valeriy Kravchuk
Sorry, but if you compile DBD::mysql with gcc, why this flag: -D_FORTEC_ is used? Can you try to compile with Sun's native compiler?
[27 Apr 2006 2:38] Andy Chen
Yes, the setting  -D_FORTEC_ was used.

Today I downgraded my Perl back to 5.6.1, and compiled again without any problem. ;-) Looks like the problem is the Perl 5.8.7 can't get alone with DBD::mysql 3.0002... 

Thanks for all the help, now I can keep working on my project!!! ;-)
[12 May 2006 9:56] Valeriy Kravchuk
Looks like the problem is not DBD::mysql-related, but rather Perl vertsion related.
[20 Jun 2006 2:36] Toby Thain
Is this a duplicate of http://bugs.mysql.com/bug.php?id=18322 (although the fix does not seem to have been implemented in the 5.0.17 package I'm using!)

I saw the same problem on Solaris 5.10 Generic_118844-26 (x86-64), trying to build DBD-mysql-3.0002 against mysql-pro-gpl-cert-5.0.17c-solaris10-x86_64.pkg, using bundled Perl 5.8.4 (though I notice 5.6.1 is also installed).

Altering the build flags for DBD::mysql resolved the library loading problem - original flags were detected as follows:

# perl Makefile.PL                                                                
...
  cflags        (mysql_config) = -I/opt/mysql/mysql/include -m64 -g -mtune=k8
  libs          (mysql_config) = -m64 -O2 -g -mtune=k8 -static-libgcc -L/opt/mysql/mysql/lib -lmysqlclient -lz -lposix4 -lgen -lsocket -lnsl -lm -lmtmalloc

Removing '-m64 -g -mtune=k8' from cflags, and '-m64 -O2 -g -mtune=k8 -static-libgcc -lmtmalloc' from libs solved the originally reported problem.

I can now move on to my next problem... Apache reports:
ld.so.1: httpd: fatal: relocation error: file /usr/perl5/site_perl/5.8.4/i86pc-solaris-64int/auto/DBD/mysql/mysql.so: symbol mysql_init: referenced symbol not found