Proper Technique for DBD::mysql install

S

sunckell

Just wondering........


I am compiling the DBD:mysql perl modules on a Solaris 10 sparc,
machine and seem to have run into an common issue.

Here is the scenario, Solaris 10 comes with mysql 4 installed in /
usr/sfw, but I need the mysql 5 client libraries to make remote
connections to a remote mysql 5 database. So I installed mysql 5 in
another location. (down /export, because the location is
automounted.) I then compiled the DBD::mysql perl module like so:

perl Makefile.PL --testdb=remote_testdb --testuser=remote_user --
testpassword=remote_passwd --testhost=remote_host --testport=3306 --
mysql_config=/export/software/mysql-5/bin/mysql_config

mysql_config returns:

Usage: ./mysql_config [OPTIONS]
Options:
--cflags [-I/export/software/mysql-5/include -g -
D_FORTEC_ -DHAVE_RWLOCK_T]
--include [-I/export/software/mysql-5/include]
--libs [-L/export/software/mysql-5/lib -
lmysqlclient -lz -lposix4 -lgen -lsocket -lnsl -lm]
--libs_r [-L/export/software/mysql-5/lib -
lmysqlclient_r -lz -lpthread -lthread -lposix4 -lgen -lsocket -lnsl -
lm -lpthread -lthread]
--socket [/tmp/mysql.sock]
--port [0]
--version [5.0.67]
--libmysqld-libs [-L/export/software/mysql-5/lib -lmysqld -lz -
lpthread -lthread -lposix4 -lgen -lsocket -lnsl -lm -lpthread -
lthread -lrt]

I am using gcc version 3.4.3 (csl-sol210-3_4-branch+sol_rpath) (which
was also used to build the perl I am using, /export/software/perl/
v5.8.4/bin/perl

When I run a make I get the following warning:

Warning: duplicate function definition 'do' detected in mysql.xs, line
225
Warning: duplicate function definition 'rows' detected in mysql.xs,
line 650

and when I run a make test:

ERROR: install_driver(mysql) failed: Can't load './DBD-mysql-4.010/
blib/arch/auto/DBD/mysql/mysql.so'


I know what the problem is... the mysql.so can't find the
mysqlclient.so file.

so I have to export LD_LIBRARY_PATH to /export/software/mysql-5/lib.
Then the make and make test run properly after that.

But if I run a simple DBI connect script I get:

install_driver(mysql) failed: Can't load '/export/software/perl/v5.8.4/
lib/site_perl/5.8.4/sun4-solaris/auto/DBD/mysql/mysql.so' for module
DBD::mysql: ld.so.1: perl: fatal: libmysqlclient.so.15: open failed:
No such file or directory at /export/software/perl/v5.8.4/lib/5.8.4/
sun4-solaris/DynaLoader.pm line 230.

but yet again if I set my LD_LIBRARY_PATH it runs correctly.

So after spending the past couple of days "googling,yahooing,
etc" it seems a possible solution is to have the script like so:

----------------------------------------------------------------------------------------
!/apps/perl/5.8.4/bin/perl
BEGIN {
unless ($ENV{BEGIN_BLOCK}) {
$ENV{LD_LIBRARY_PATH} = "/export/software/mysql-5/lib";
$ENV{BEGIN_BLOCK} = 1;
exec 'env',$0,@ARGV;
}
}

use strict;
use warnings;
use DBI;

my $db_user = 'remote_user';
my $db_pass = 'remote_passwd';
my $db_host = 'remote_host';
my $db_name = 'remote_db';
my $db_type = 'mysql';
my $db_port = '3306';
my $db_dsn = "DBI:$db_type:$db_name:$db_host:$db_port";


my $db_con = DBI->connect($db_dsn, $db_user, $db_pass)
|| die "Failed DB Connection: $DBI::errstr\n";

-------------------------------------------------------------------------------------------------------------------

but it seems like a 1/2 a55ed solution. I would think I should be
able to compile the DBD::mysql module to have the so always look in
the directory I tell it to for the mysql client and not rely on ld.so.
1 for it's library path or LD_LIBRARY_PATH.

I'm sure other people have had similar experiences. Is this the way
to go, or is there a better way to do it?


Thanks,
Chad
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,733
Messages
2,569,439
Members
44,829
Latest member
PIXThurman

Latest Threads

Top