http://www.perlmonks.org?node_id=793727

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

I did some additional research and I believe the source of the problems above is a 64 bit MySQL database and 32 bit Perl - at least in the past I recall having to deinstall the 64 bit mysql program and install the 23 bit version for DBD to work. The fact that Perl 5.10 is supposed to support 64 bit now muddies those waters but, nevertheless, I did perform the 32 bit reinstall. I also was able to get DBD:mysql to compile properly. However, I am still getting errors when I run my script:
finhagens-macbook-pro:perl finhagen$ ./tme_ext_full.pl dyld: lazy symbol binding failed: Symbol not found: _mysql_init Referenced from: /Library/Perl/5.10.0/darwin-thread-multi-2level/aut +o/DBD/mysql/mysql.bundle Expected in: flat namespace dyld: Symbol not found: _mysql_init Referenced from: /Library/Perl/5.10.0/darwin-thread-multi-2level/aut +o/DBD/mysql/mysql.bundle Expected in: flat namespace Trace/BPT trap
I googled this error but I didn't find any references that explained how to fix this problem. Any suggestions?

Hagen

I recently upgraded my MAC OS to the latest Snow Leopard 10.6 release. Among other things it broke DBD:mysql. I tried reinstalling perl 5.10 and the DBD::mysql module using CPAN. When I try to install DBD::mysql I get the following error:
cpan[10]> install DBD:mysql Running install for module 'DBD::mysql' Running make for C/CA/CAPTTOFU/DBD-mysql-4.012.tar.gz Has already been unwrapped into directory /Users/finhagen/.cpan/buil +d/DBD-mysql-4.012-TzlSls Has already been made Running make test PERL_DL_NONLAZY=1 /usr/bin/perl "-MExtUtils::Command::MM" "-e" "test_h +arness(0, 'blib/lib', 'blib/arch')" t/*.t t/00base....................ok 1/6 + # Failed test 'use DBD::mysql;' # at t/00base.t line 21. # Tried to use 'DBD::mysql'. # Error: Can't load '/Users/finhagen/.cpan/build/DBD-mysql-4.012- +TzlSls/blib/arch/auto/DBD/mysql/mysql.bundle' for module DBD::mysql: +dlopen(/Users/finhagen/.cpan/build/DBD-mysql-4.012-TzlSls/blib/arch/a +uto/DBD/mysql/mysql.bundle, 2): Symbol not found: _is_prefix # Referenced from: /Users/finhagen/.cpan/build/DBD-mysql-4.012-TzlSl +s/blib/arch/auto/DBD/mysql/mysql.bundle # Expected in: flat namespace # in /Users/finhagen/.cpan/build/DBD-mysql-4.012-TzlSls/blib/arch/aut +o/DBD/mysql/mysql.bundle at /System/Library/Perl/5.10.0/darwin-thread +-multi-2level/DynaLoader.pm line 207. # 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 2/6FAILED--Further testing stopped: Un +able to load DBD::mysql make: *** [test_dynamic] Error 9 CAPTTOFU/DBD-mysql-4.012.tar.gz /usr/bin/make test -- NOT OK //hint// to see the cpan-testers results for installing this module, t +ry: reports CAPTTOFU/DBD-mysql-4.012.tar.gz Running make install make test had returned bad status, won't install without force Failed during this command: CAPTTOFU/DBD-mysql-4.012.tar.gz : make_test NO
When I try and run the script that calls the DBD module I get this error:
finhagens-macbook-pro:perl finhagen$ ./tme_ext_full.pl Can't locate DBD/mysql.pm in @INC (@INC contains: /Library/Perl/Update +s/5.10.0/darwin-thread-multi-2level /Library/Perl/Updates/5.10.0 /Sys +tem/Library/Perl/5.10.0/darwin-thread-multi-2level /System/Library/Pe +rl/5.10.0 /Library/Perl/5.10.0/darwin-thread-multi-2level /Library/Pe +rl/5.10.0 /Network/Library/Perl/5.10.0/darwin-thread-multi-2level /Ne +twork/Library/Perl/5.10.0 /Network/Library/Perl /System/Library/Perl/ +Extras/5.10.0/darwin-thread-multi-2level /System/Library/Perl/Extras/ +5.10.0 .) at ./tme_ext_full.pl line 31. BEGIN failed--compilation aborted at ./tme_ext_full.pl line 31.
I seem to recall an issue like this in the past but I can't remember what I did to address it. Any help would be greatly appreciated. Thanks!

Hagen Finley

Boulder, CO

Replies are listed 'Best First'.
Re: MAC OS 10.6 upgrade breaks DBD:mysql
by perrin (Chancellor) on Sep 06, 2009 at 02:30 UTC
    It breaks MySQL server as well. Possible solutions here.
Re: MAC OS 10.6 upgrade breaks DBD:mysql
by romkey (Acolyte) on Sep 06, 2009 at 12:46 UTC

    I had to reinstall MySQL when I installed Snow Leopard, but had no problems beyond that.

    People starting out on this should make sure that you install XCode from the optional installs, otherwise you'll be missing important things like make and the compiler (obviously you already did this, superdoc).

    I downloaded the latest 64 bit MySQL from mysql.com, installed it, started it, and reinstalled DBD::mysql under CPAN and everything then worked.

    You'll need to rebuild your actual databases after doing this.

      Thanks! I did some additional research and I believe the source of the problems above is a 64 bit MySQL database and 32 bit Perl - at least in the past I recall having to deinstall the 64 bit mysql program and install the 23 bit version for DBD to work. The fact that Perl 5.10 is supposed to support 64 bit now muddies those waters but, nevertheless, I did perform the 32 bit reinstall. I also was able to get DBD:mysql to compile properly. However, I am still getting errors when I run my script:
      finhagens-macbook-pro:perl finhagen$ ./tme_ext_full.pl dyld: lazy symbol binding failed: Symbol not found: _mysql_init Referenced from: /Library/Perl/5.10.0/darwin-thread-multi-2level/aut +o/DBD/mysql/mysql.bundle Expected in: flat namespace dyld: Symbol not found: _mysql_init Referenced from: /Library/Perl/5.10.0/darwin-thread-multi-2level/aut +o/DBD/mysql/mysql.bundle Expected in: flat namespace Trace/BPT trap
      I googled this error but I didn't find any references that explained how to fix this problem. Any suggestions?

      Hagen Finley

      Boulder, CO

        I'm running the stock Perl 5.10.0 that came with Snow Leopard, and it's definitely running as a 64 bit app on my machine. For me, the version of Perl 5.10.0 that shipped with Snow Leopard worked okay with a fresh install of 64 bit MySQL and clean build of DBD::mysql

        I wonder if you're seeing problems from multiple incompatible versions of Perl libs being installed or having a library path issue?

        I get the same error---except when I run my script as root using sudo. Why should it need, or even want, to run as root? To be more precise,
        me% perl -MDBD::mysql -e 'print "hello\n"'
        works fine, as does
        me% sudo perl checkin.pl
        (which connects to a database on another server, ie, not localhost). But
        me% perl checkin.pl
        produces the error Hagen describes above. Any ideas would be most welcome.

        I am running 10.6.1. I ripped out my previous MySQL and DBD::mysql installations, reinstalled MySQL 5.1.38 for x86_64 using the package installer from mysql.com, and manually installed DBD::mysql 4.012 with Perl Makefile.PL, etc. There were an awful lot of warnings on "make". Perhaps it is relevant that "make test" failed but "sudo make test" succeeded.

        The error message from "make test" was to me uninformative. I will copy just the first few lines here:

        % make test PERL_DL_NONLAZY=1 /usr/bin/perl "-MExtUtils::Command::MM" "-e" "test_h +arness(0, 'blib/lib', 'blib/arch')" t/*.t t/00base....................ok 1/6 + # Failed test 'use DBD::mysql;' # at t/00base.t line 21. # Tried to use 'DBD::mysql'. # Error: Can't load '/Users/zteitler/Installers/DBD-mysql-4.012/b +lib/arch/auto/DBD/mysql/mysql.bundle' for module DBD::mysql: dlopen(/ +Users/zteitler/Installers/DBD-mysql-4.012/blib/arch/auto/DBD/mysql/my +sql.bundle, 2): Symbol not found: _is_prefix
        Any comments or suggestions would be most welcome.
      s/superdoc/finhagen/ (should drink my coffee before writing things)
Re: dyld: lazy symbol binding failed (was MAC OS 10.6 upgrade breaks DBD:mysql)
by GrandFather (Saint) on Mar 04, 2010 at 02:54 UTC

    I just had the same 'dyld: lazy symbol binding failed: ...' issue. The key seems to be that the word width of the mysql install must match the running Perl's word width. That can be a bit subtle because the default Mac SnowLeopard Perl build seems to be 'fat' and what happens at run time depends on the word width the OS is using.

    The 'solution' is, if it doesn't work install mysql with the other word width. The catch is that you then need to reinstall DBD::mysql and that means you first have to uninstall it. The easiest way to do that seems to be:

    sudo rm -rf /Library/Perl/5.10.0/darwin-thread-multi-2level/auto/DBD sudo rm -rf /Library/Perl/5.10.0/darwin-thread-multi-2level/DBD

    although if you have other DBD modules installed that may be a bit nasty!


    True laziness is hard work
      Gramps! If you were in the U.S. right now, I'd wish you a happy Father's Day, since that is applicable at the moment here. (But I gather Australia's on the other side of the Date-line, and maybe doesn't even have this concept of one day for making fathers feel like they can get special attention.)

      Anyway, I have run into the exact problem described in one of the posts above: macosx 10.6 (snow leopard, replacing a previous 10.5 on my macbook), Perl 5.10.0 (x86_64, as per the macosx distro), newly installed mysql 5.1.48 64-bit (replacing a 5.0.1 32-bit version that had been working fine with osx 10.5): DBI/DBD::mysql newly installed (the latter by hand, to get the tests to pass), and now a simple one-liner like this:

      perl -MDBI -le '$d=DBI->connect("DBI:mysql:database=test;host=localhos +t","test",""); print "ok"'
      Works fine when run as root, but fails (with the thread-topic error message) when run as me.

      Your explanation sounded like something I might be able get my head around, but alas, I don't know what you're talking about. Where/how do I control or learn about this "word width" issue?

      Actually, it turns out this anonymonk reply above had the right answer: a typical root shell in this sort of setup does not have "VERSIONER_PERL_PREFER_32_BIT=yes" when perl runs, whereas my own personal login account does. Of course, I don't have anything like this showing up in my normal shell environment -- it only shows up when I run perl, and if I change $ENV{VERSIONER_PERL_PREFER_32_BIT} to "no" inside a perl script, it's already too late to take effect (DBD::mysql still fails).

      Luckily, if I this to my .bashrc file, perl pays attention, and DBD::mysql works (finally!!!)

      export VERSIONER_PERL_PREFER_32_BIT=no
      So, to recap my voyage through this morass...
      1. upgraded from macosx 10.5 to 10.6, causing upgrade from perl 5.8.8 +to 5.10.0, and therefore... 2. had to "mysqldump --database each_db_needed | gzip > each_db_needed +.dump.gz (update) 2b. Shut down running mysqld 3. had to install mysql 5.1.48 64-bit (macosc binary distro) 4. change "/usr/local/mysql" symlink target from mysql-5.0.1 to mysql- +5.1.48 (update) 4b. Start mysqld 5. gunzip < each_db_needed.dump.gz | mysql 6. set up mysql accounts and passwords 7. install DBI (standard cpan style) 8. install DBD::mysql (by hand -- for some reason, 'testuser' needed t +weaking) 9. add 'export VERSIONER_PERL_PREFER_32_BIT=no' to my .bashrc 10. hope that step 9 doesn't break lots of other stuff...
      This thread has proven to me once again how valuable perlmonks is. I'm moved to donate more money.
        This old problem is new to me since I just installed os x 10.6 and upgraded to 10.6.8. My system c2d hence 64 bit, the perl is 5.10.0 from apple, 64bit too, and I installed mysql 5.1.63 for mac 10.6 64bit from a downloaded dmg. But these didn't save me from errors:
        dyld: lazy symbol binding failed: Symbol not found: _mysql_init Referenced from: /Library/Perl/5.10.0/darwin-thread-multi-2level/aut +o/DBD/mysql/mysql.bundle Expected in: flat namespace dyld: Symbol not found: _mysql_init Referenced from: /Library/Perl/5.10.0/darwin-thread-multi-2level/aut +o/DBD/mysql/mysql.bundle Expected in: flat namespace ========================
        So what's the easiest fix? Thanks a lot
Re: dyld: lazy symbol binding failed (was MAC OS 10.6 upgrade breaks DBD:mysql)
by kyz (Acolyte) on Oct 14, 2009 at 17:09 UTC
    I'm not sure if it applies to everybody, but I had this problem because I use the MySQL packages provided by Fink, but had not upgraded Fink to Mac OS X 10.6.

    As a result, all my Fink libraries, including mysqlclient.dylib are 32-bit only.

    The /usr/bin/perl in Snow Leopard is 32-or-64 bit, but prefers 64 bit. By the time it's loaded, it's definitely 64 bit and all further (runtime) libraries linked in HAVE to be 64-bit.

    My solution is twofold: firstly, upgrade Fink into 64-bit land by reinstalling from scratch, as per their instructions. Secondly, I've decided to use the official MySQL build rather than Fink's build.

    That's the bottom-line, but here are some other useful tips:

    • otool -L will tell you what other libraries a bundle depends on.
    • file on an executable will tell you what architectures it's compiled for.
    In this case:
    $ otool -L blib/arch/auto/DBD/mysql/mysql.bundle blib/arch/auto/DBD/mysql/mysql.bundle: /sw/lib/mysql/libmysqlclient.15.dylib (compatibility version 1 +6.0.0, current version 16.0.0) /usr/lib/libz.1.dylib (compatibility version 1.0.0, current ve +rsion 1.2.3) /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, curre +nt version 124.1.1) $ file /sw/lib/mysql/libmysqlclient.15.dylib /sw/lib/mysql/libmysqlclient.15.dylib: Mach-O dynamically linked share +d library i386 $ file blib/arch/auto/DBD/mysql/mysql.bundle blib/arch/auto/DBD/mysql/mysql.bundle: Mach-O universal binary with 3 +architectures blib/arch/auto/DBD/mysql/mysql.bundle (for architecture x86_64): + Mach-O 64-bit bundle x86_64 blib/arch/auto/DBD/mysql/mysql.bundle (for architecture i386): Mach-O + bundle i386 blib/arch/auto/DBD/mysql/mysql.bundle (for architecture ppc7400): + Mach-O bundle ppc
Re: dyld: lazy symbol binding failed (was MAC OS 10.6 upgrade breaks DBD:mysql)
by Anonymous Monk on Jun 15, 2010 at 06:58 UTC
    In my case, DBD::mysql once worked but failed recently. The reason was I installed fink binary recently. When I removed /sw fink installed, DBD::mysql become again working.
    In my case, otool and file commands suggested by the comment "by kyz on Oct 14, 2009 at 17:09 UTC" indicated all is fine (no lib in /sw was listed). May the failure comes from some other dependency. Mickey
      I miswrote about fink. No binary of fink for X.6 at this moment (2010/06/15). In fact, I installed fink from source (fink-0.29.10.tar.gz), followed the instruction page (http://www.finkproject.org/download/srcdist.php). I don't know whether it installed 64bit-fink or not and how it can be set. Still, once I removed /sw, DBD::mysql worked again. Mickey