Bug #30220 Can't run DBD:mysql
Submitted: 3 Aug 2007 5:38 Modified: 4 Aug 2007 5:10
Reporter: Sheila Podell Email Updates:
Status: Duplicate Impact on me:
None 
Category:Connectors: DBD::mysql ( Perl ) Severity:S1 (Critical)
Version:4.005 OS:MacOS (10.4.10 MacPro)
Assigned to: CPU Architecture:Any

[3 Aug 2007 5:38] Sheila Podell
Description:
I am not able to successfuly load the DBD:mysql module with MySQL: 5.0.45. There seems to be some sort of discrepancy between where DBD:mysql looks for dynamic libraries and where mysql_config reports them to be. I have tried to resolve this conflict in two different ways 1) manually specifying correct paths using --cflags and --libs options on the command line for the perl Makefile.PL 2) adding soft links to the dynamic library paths in places where I think DBD:mysql is looking for them. Neither of these methods has been successful. I desperately need to be able to install and run this DBD module with MySQL on this machine. Any help would be greatly appreciated.

The version of MySQL I am using was a pre-compiled binary. The authors of DBD:mysql suggest that there may be issues if different compiler versions are used for MySQL and DBD:mysql. Is this true? I have read (I think in some of the MySQL documentation) that the pre-compiled MySQL binaries are usually more efficient than I might be able to build myself, being relatively inexperienced at this. I have no idea how the MySQL compilation for OSX was done, so I don't know if this is a factor in the problem I'm having.

Details of the installation follow. Thanks for your help.

- Sheila Podell

	
	MySQL 5.0.45, Perl 5.8.6, DBI and are successfully installed on my MacbookPro (OSX 10.4.10). CPAN wasn't able handle installing DBD:mysql 4.005, so I downloaded it manually, and created a custom makefile as described at:
	
		http://jayallen.org/journey/2006/04/dbd-mysql-build-problems-on-mac-book-pro

	Paths in this makefile match mysql_config output. I verified by command line search that the headers and dynamic library files do truly exist in the directories indicated. 
	
	$ perl Makefile.PL \
 --cflags="-I/usr/local/mysql/include -Os -arch i386 -fno-common" \
 --libs="-L/usr/local/mysql/lib -lmysqlclient -lz -lm"	
	
Makefile.PL Output:
#######################
  cflags        (User's choice) = -I/usr/local/mysql/include -Os -arch i386 -fno-common
  embedded      (mysql_config ) = 
  libs          (User's choice) = -L/usr/local/mysql/lib -lmysqlclient -lz -lm
  mysql_config  (guessed      ) = mysql_config
  nocatchstderr (default      ) = 0
  nofoundrows   (default      ) = 0
  ssl           (guessed      ) = 0
  testdb        (default      ) = test
  testhost      (default      ) = 
  testpassword  (default      ) = 
  testsocket    (default      ) = 
  testuser      (default      ) = 

To change these settings, see 'perl Makefile.PL --help' and
'perldoc INSTALL'.

Using DBI 1.58 (for perl 5.008006 on darwin-thread-multi-2level) installed in /Library/Perl/5.8.6/darwin-thread-multi-2level/auto/DBI/
Writing Makefile for DBD::mysql
#######################

Paths in the makefile match mysql_config output:	
	$ mysql_config --cflags --libs
-I/usr/local/mysql/include -Os -arch ppc -fno-common
-L/usr/local/mysql/lib -lmysqlclient -lz -lm

make test fails miserably, starting from the very first test:
#######################
PERL_DL_NONLAZY=1 /usr/local/bin/perl "-MExtUtils::Command::MM" "-e" "test_harness(0, 'blib/lib', 'blib/arch')" t/*.t
t/00base.............ok 3/5install_driver(mysql) failed: Can't load
'/Users/spodell/Desktop/build/DBD-mysql-4.005/blib/arch/auto/DBD/
mysql/mysql.bundle' for module DBD::mysql:
dlopen(/Users/spodell/Desktop/build/DBD-mysql-4.005/blib/arch/auto/
DBD/mysql/mysql.bundle, 2): Symbol not found: _mysql_stmt_store_result
  Referenced from: /Users/spodell/Desktop/build/DBD-mysql-4.005/blib/arch/auto/DBD/mysql/mysql.bundle
  Expected in: dynamic lookup
 at (eval 3) line 3
Compilation failed in require at (eval 3) line 3.
Perhaps a required shared library or dll isn't installed where expected
 at t/00base.t line 38
t/00base.............dubious                                                 
        Test returned status 255 (wstat 65280, 0xff00)
DIED. FAILED tests 4-5
        Failed 2/5 tests, 60.00% okay
. . .
<lots of other failed tests after this>
#######################
If I add a soft link to the library directory, either before or after creating the makefile and running make, this doesn't help, although it does change mysql_config output:

	ln -s /usr/local/mysql/lib/ /usr/local/mysql/lib/mysql
	$ mysql_config --cflags --libs
	-I/usr/local/mysql/include -Os -arch ppc -fno-common
	-L/usr/local/mysql/lib/mysql -lmysqlclient -lz -lm

I tried ignoring the make test. make install ran without errors: 

#######################
cc -c  -I/Library/Perl/5.8.6/darwin-thread-multi-2level/auto/DBI -I/usr/local/mysql/include -Os -arch i386 -fno-common -DDBD_MYSQL_INSERT_ID_IS_GOOD -g  -g -pipe -fno-common -DPERL_DARWIN -no-cpp-precomp -fno-strict-aliasing -I/usr/local/include -O3   -DVERSION=\"4.005\" -DXS_VERSION=\"4.005\"  "-I/System/Library/Perl/5.8.6/darwin-thread-multi-2level/CORE"   dbdimp.c
cc -c  -I/Library/Perl/5.8.6/darwin-thread-multi-2level/auto/DBI -I/usr/local/mysql/include -Os -arch i386 -fno-common -DDBD_MYSQL_INSERT_ID_IS_GOOD -g  -g -pipe -fno-common -DPERL_DARWIN -no-cpp-precomp -fno-strict-aliasing -I/usr/local/include -O3   -DVERSION=\"4.005\" -DXS_VERSION=\"4.005\"  "-I/System/Library/Perl/5.8.6/darwin-thread-multi-2level/CORE"   mysql.c
Running Mkbootstrap for DBD::mysql ()
chmod 644 mysql.bs
rm -f blib/arch/auto/DBD/mysql/mysql.bundle
LD_RUN_PATH="/usr/local/mysql/lib" /usr/local/bin/perl myld env MACOSX_DEPLOYMENT_TARGET=10.3 cc  -bundle -undefined dynamic_lookup -L/usr/local/lib dbdimp.o mysql.o  -o blib/arch/auto/DBD/mysql/mysql.bundle   -L/usr/local/mysql/lib -lmysqlclient -lz -lm   
chmod 755 blib/arch/auto/DBD/mysql/mysql.bundle
cp mysql.bs blib/arch/auto/DBD/mysql/mysql.bs
chmod 644 blib/arch/auto/DBD/mysql/mysql.bs
Manifying blib/man3/DBD::mysql.3pm
Manifying blib/man3/DBD::mysql::INSTALL.3pm
Manifying blib/man3/Bundle::DBD::mysql.3pm
Files found in blib/arch: installing files in blib/lib into architecture dependent library tree
Installing /Library/Perl/5.8.6/darwin-thread-multi-2level/DBD/mysql.pm
Writing /Library/Perl/5.8.6/darwin-thread-multi-2level/auto/DBD/mysql/.packlist
Appending installation info to //System/Library/Perl/5.8.6/darwin-thread-multi-2level/perllocal.pod
#######################
At run time, the DBD:mysql module fails when called in a perl script (this same script works fine on a Solaris machine with DBD:mysql installed successfully).
##############
$ ./sql_query_test.pl test test_query <my perl script>

dyld: lazy symbol binding failed: Symbol not found: _mysql_server_init
  Referenced from: /Library/Perl/5.8.6/darwin-thread-multi-2level/auto/DBD/mysql/mysql.bundle
  Expected in: dynamic lookup

dyld: Symbol not found: _mysql_server_init
  Referenced from: /Library/Perl/5.8.6/darwin-thread-multi-2level/auto/DBD/mysql/mysql.bundle
  Expected in: dynamic lookup

How to repeat:
Try to install DBD:mysql module 4.005 in combination with MySQL 5.0.45 on OSX 10.4.10, MacPro.
[3 Aug 2007 7:50] Sveta Smirnova
Thank you for the report.

Please revert patch, run perl Makefile.PL --help, find how to indicate path to real mysql_config, indicate it and recompile DBD::mysql. Then run tests. Also please not there is bug #28544 which can affect the installation. Use workaraound as described in comment "[1 Aug 13:05] Sveta Smirnova" to bug #30160
[3 Aug 2007 7:51] Sveta Smirnova
And inform us about results of your trying.
[3 Aug 2007 15:00] Sheila Podell
The MySQL 5.0 and 5.1 manuals (http://dev.mysql.com/doc/refman/5.0/en/mac-os-x.html) say the binary distribution for Mac OSX was compiled uising Darwin 6.3, and gives flags for that build. Surely this can't still be true? The current version of Darwin in OS X 10.4.10 is 7.9.
[3 Aug 2007 22:16] Sheila Podell
Thanks for your swift response, and sorry for the duplication - the problem I reported is the same as #30160, and the workaround you suggested was succesful. Additional symptoms I reported were due to an eariler mistake I had made, installing the wrong version of MySQL for my hardware (osx10.4-powerpc  instead or osx10.4-i686). Thanks for your patience.
[4 Aug 2007 5:10] Valeriy Kravchuk
Duplicate of bug #30160.
[4 Aug 2007 5:13] Valeriy Kravchuk
And duplicate of bug #28544 eventually.