Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Installation error for DBD::MySQL on OSX v10.6.6

I'm attempting to get DBD::MySQL working on Snow Leopard (v10.6.6). The default version of Perl that comes with the OS is v5.10.0. Since I've read that's 64-bit, I went ahead and downloaded and installed a 64-bit version of MySQL (mysql-5.5.8-osx10.6-x86_64).

Installing and setting up MySQL went smoothly, here's my config and version number for reference.

I used CPAN to download DBI and the DBD::MySQL drivers. I then:

  • Installed DBI
  • Setup a Makefile.PL
  • Ran the make command from the command line

The Makefile.PL said it would use the following settings for compiling and testing:

I will use the following settings for compiling and testing:

  cflags        (mysql_config ) = -I/usr/local/mysql/include  -Os -g -fno-common -fno-strict-aliasing -arch x86_64
  embedded      (mysql_config ) = 
  libs          (mysql_config ) = -L/usr/local/mysql/lib -lmysqlclient   -lpthread
  mysql_config  (guessed      ) = mysql_config
  nocatchstderr (default      ) = 0
  nofoundrows   (default      ) = 0
  ssl           (guessed      ) = 0
  testdb        (default      ) = test
  testhost      (default      ) = 
  testpassword  (User's choice) = r00t!
  testsocket    (default      ) = 
  testuser      (User's choice) = root

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

Multiple copies of Driver.xst found in: /Library/Perl/5.10.0/darwin-thread-multi-2level/auto/DBI/ /System/Library/Perl/Extras/5.10.0/darwin-thread-multi-2level/auto/DBI/ at Makefile.PL line 907
Using DBI 1.616 (for perl 5.010000 on darwin-thread-multi-2level) installed in /Library/Perl/5.10.0/darwin-thread-multi-2level/auto/DBI/
Writing Makefile for DBD::mysql

Everything seemed to be going fine, until I tried to run make test :

t/00base....................NOK 2/6#     Tried to use 'DBD::mysql'.          
#     Error:  Can't load '/Users/swm/.cpan/build/DBD-mysql-4.018-Pnd2qz/blib/arch/auto/DBD/mysql/mysql.bundle' for module DBD::mysql: dlopen(/Users/swm/.cpan/build/DBD-mysql-4.018-Pnd2qz/blib/arch/auto/DBD/mysql/mysql.bundle, 2): Library not loaded: libmysqlclient.16.dylib
#   Referenced from: /Users/swm/.cpan/build/DBD-mysql-4.018-Pnd2qz/blib/arch/auto/DBD/mysql/mysql.bundle
#   Reason: image not found at /System/Library/Perl/5.10.0/darwin-thread-multi-2level/DynaLoader.pm line 207.
#  at (eval 7) line 2
# Compilation failed in require at (eval 7) line 2.
# BEGIN failed--compilation aborted at (eval 7) line 2.
FAILED--Further testing stopped: Unable to load DBD::mysql
make: *** [test_dynamic] Error 9

It's failing because it can't seem to find the mysql.bundle for DBD. Has anyone come across this problem? Or can point me in the right direction on what to try next? I need DBI/DBD::MySQL for my new job and I'm scrambling to find a solution.

Many thanks in advance.

like image 584
Scott McCracken Avatar asked Jan 27 '11 20:01

Scott McCracken


3 Answers

I got around the "Library not loaded: libmysqlclient.16.dylib" problem by placing a symbolic link in /usr/lib/" to /usr/local/mysql-5.5.8-osx10.6-x86_64/lib/libmysqlclient.16.dylib

like image 119
RonN Avatar answered Oct 06 '22 01:10

RonN


I worked around the same or a similar issue. Somehow I could build and test DBD::mysql with cpan but when I tried to use it in a script it said things like

dyld: lazy symbol binding failed: Symbol not found: _mysql_init
  Referenced from: /Library/Perl/5.10.0/darwin-thread-multi-2level/auto/DBD/mysql/mysql.bundle
  Expected in: flat namespace

Apparently, it's a 64-bit vs 32-bit issue.

Installing the fink dbd-mysql-pm5100 package made it work though it took kind of a long time. I also removed the cpan-installed version:

sudo rm -rf /Library/Perl/5.10.0/darwin-thread-multi-2level/auto/DBD/mysql
sudo rm -rf /Library/Perl/5.10.0/darwin-thread-multi-2level/DBD/mysql
sudo rm -rf /Library/Perl/5.10.0/darwin-thread-multi-2level/DBD/mysql.pm 
like image 42
Nathan Avatar answered Oct 06 '22 00:10

Nathan


also include in .profile

export VERSIONER_PERL_PREFER_32_BIT=yes; 

Besides creating the link the executions of the program with DBI::mysql generated an error, thus including this variable on the environment make it works

like image 27
ylm Avatar answered Oct 06 '22 01:10

ylm