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

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

I am trying to install DBD-mysql-4.022 on RHEL5 2.6.18-194.el5 box. I have two versions of Perl on the given box (5.8.8 - default & 5.16.1)

Installation of DBD-mysql-4.022 failed with the following error:

# Error: Can't load '/root/.cpan/build/DBD-mysql-4.022/blib/arch/ +auto/DBD/mysql/mysql.so' for module DBD::mysql: /root/.cpan/build/DBD +-mysql-4.022/blib/arch/auto/DBD/mysql/mysql.so: undefined symbol: mys +ql_get_server_version at /usr/lib64/perl5/5.8.8/x86_64-linux-thread-m +ulti/DynaLoader.pm line 230.

I found that this can be fixed by specifying path to libmysqlclient.a

Ref: http://cpansearch.perl.org/src/JWIED/DBD-mysql-2.1012/INSTALL.html#known%20problems
[root@RHEL5 DBD-mysql-4.022]# perl Makefile.PL --libs='/usr/lib64/mysq +l/libmysqlclient.a' PLEASE NOTE: For 'make test' to run properly, you must ensure that the database user 'root' can connect to your MySQL server and has the proper privileges that these tests require such as 'drop table', 'create table', 'drop procedure', 'create procedure' as well as others. mysql> grant all privileges on test.* to 'root'@'localhost' identified + by 's3kr1t'; You can also optionally set the user to run 'make test' with: perl Makefile.PL --testuser=username I will use the following settings for compiling and testing: cflags (mysql_config ) = -I/usr/include/mysql -g -pipe -Wp,-D +_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-s +ize=4 -m64 -fPIC -g -static-libgcc -fno-omit-frame-pointer -fno-stric +t-aliasing -DMY_PTHREAD_FASTMUTEX=1 embedded (mysql_config ) = libs (User's choice) = /usr/lib64/mysql/libmysqlclient.a mysql_config (guessed ) = mysql_config nocatchstderr (default ) = 0 nofoundrows (default ) = 0 ssl (guessed ) = 0 testdb (default ) = test testhost (default ) = testpassword (default ) = testsocket (default ) = testuser (guessed ) = root To change these settings, see 'perl Makefile.PL --help' and 'perldoc INSTALL'. Checking if your kit is complete... Looks good Unrecognized argument in LIBS ignored: '/usr/lib64/mysql/libmysqlclien +t.a' Multiple copies of Driver.xst found in: /usr/lib64/perl5/site_perl/5.8 +.8/x86_64-linux-thread-multi/auto/DBI/ /usr/lib64/perl5/vendor_perl/5 +.8.8/x86_64-linux-thread-multi/auto/DBI/ at Makefile.PL line 941 Using DBI 1.622 (for perl 5.008008 on x86_64-linux-thread-multi) insta +lled in /usr/lib64/perl5/site_perl/5.8.8/x86_64-linux-thread-multi/au +to/DBI/ Writing Makefile for DBD::mysql Writing MYMETA.yml and MYMETA.json
As we can see above, DBD-mysql is referring to the default (5.8.8) perl. I am not sure how to tell Makefile.pl to refer the latest installed perl i.e., 5.16.1. I saw that the Makefile.pl has the following entry to find the perl installation:
use Config; exec ($Config{perlpath}, $0, @ARGV )|| die $!;
Now i know that if i prepend my latest (5.16.1) perl installation path to the variable PATH, it might work but my concern is that later if i revert the settings in PATH, then will DBD-mysql still use Perl version 5.16.1? I am asking this mainly because i don't want to disturb the existing PATH settings for applications that require Perl 5.8.8 and at the same time want to ensure that DBD-mysql always refers the latest perl i.e., 5.16.1.

Also, how can i undo what i have done by using perl Makefile.PL --libs='/usr/lib64/mysql/libmysqlclient.a' just to make sure that everything is clean?

Replies are listed 'Best First'.
Re: Specify particular Perl path to a module during installation
by space_monk (Chaplain) on Nov 29, 2012 at 20:49 UTC

    AFAIK, as long as the PATH points to the right PERL, the rest should follow on naturally. You might want to set PERL5LIB too.

    You shouldn't revert the path; any program that uses your 5.16.1 version should have the correct environment to run in.

    Your program can of course check which version it is running by means of a use 5.16.1;

    Someone correct me if I've got any of the above wrong :-)

    A Monk aims to give answers to those who have none, and to learn from those who know more.
Re: Specify particular Perl path to a module during installation
by CountZero (Bishop) on Nov 29, 2012 at 20:59 UTC
    Could it be that when you run perl Makefile.PL you run the default Perl? You could edit the Makefile.PL to point to your perl 5.16.1.

    CountZero

    A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James

    My blog: Imperial Deltronics
      I don't think you have to edit Makefile.PL at all as long as you are sure the PATH environment variable points to the 5.16.1 version of perl first before you build the module. Just do perl -v from the command line before running Makefile.PL to make sure.
      A Monk aims to give answers to those who have none, and to learn from those who know more.
        True, but many programs and services on your computer may rely on the "system" Perl to do their jobs. Switching wholesale to a newer Perl may very well cause all kinds of havoc that will be difficult to trace. I'd rather not mess around with such global options, unless there is absolutely no other solution available.

        CountZero

        A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James

        My blog: Imperial Deltronics