Bug #4670 Perl DBD::mysql compilation reports libmysqlclient.a error
Submitted: 21 Jul 2004 14:13 Modified: 14 Sep 2004 18:26
Reporter: Mike Blazer Email Updates:
Status: Closed Impact on me:
Category:MySQL Server Severity:S2 (Serious)
Version:4.0.20 OS:Linux (Gentoo Linux)
Assigned to: Bugs System

[21 Jul 2004 14:13] Mike Blazer
Hi there!
I was compiling perl mysql driver - DBD::mysql on AMD64 machine.
Mysql was installed from binary distribution mysql-max-4.0.20-unknown-linux-x86_64.tar.gz
and mysqld itself works fine.

But DBD::mysql compilation was aborted saying:

/usr/lib/gcc-lib/x86_64-pc-linux-gnu/3.3.3/../../../../x86_64-pc-linux-gnu/bin/ld: /host/mysql/lib/libmysqlclient.a(libmysql.o): relocation R_X86_64_32S can not be used when making a shared object; recompile with -fPIC
/host/mysql/lib/libmysqlclient.a: could not read symbols: Bad value

Then I tried mysql-standard distribution (same, AMD64 one) and got the same result.
So, I'm assuming it's libmysqlclient.a bug.

Thanks in advance, any help is much appreciated!

Always been a huge mysql fan!

Thanks, Mike

How to repeat:
I guess AMD64 server with Gentoo with the same mysql distribution and the last version of DBD::mysql will show this bug
[26 Jul 2004 23:36] Mike Blazer
Hello, it's Mike, who started this bug report.
Well, that's not any programming bug - I easilly compiled libmysqlclient.a with -fPIC option. It's just that both distributions are sort of broken.

So, you can mark it lower then High/Serious

[17 Aug 2004 22:03] Patrick Galbraith
I need to test this on a 64-bit box, and am wondering if perhaps 'perl Makefile.pl' was unable to use the values from 'mysql_config' to generate proper compile flags in the Makefile.
[2 Sep 2004 3:05] Patrick Galbraith
I could get DBD::mysql to compile on my AMD test platform, but make test fails.

Now, this is with the latest code, which I've modified Makefile.PL to correctly find mysql_config which will give the correct compile options. The problem I have is in 'make test', and it seems that there is a problem loading modules.

Also, I'm testing as a regular user. I would really like to test as root to rule out any issues with whether the user I'm using is the problem.

This is my output:

mysqldev@melody:~/test/dbd-mysql> make
cc -c  -I/usr/lib/perl5/site_perl/5.8.0/x86_64-linux-thread-multi/auto/DBI -I/home/mysqldev/test/mysql/include -g  -D_REENTRANT -D_GNU_SOURCE -fno-strict-aliasing -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -O2 --pipe   -DVERSION=\"2.9003\" -DXS_VERSION=\"2.9003\" -fPIC "-I/usr/lib/perl5/5.8.0/x86_64-linux-thread-multi/CORE"   dbdimp.c
cc -c  -I/usr/lib/perl5/site_perl/5.8.0/x86_64-linux-thread-multi/auto/DBI -I/home/mysqldev/test/mysql/include -g  -D_REENTRANT -D_GNU_SOURCE -fno-strict-aliasing -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -O2 --pipe   -DVERSION=\"2.9003\" -DXS_VERSION=\"2.9003\" -fPIC "-I/usr/lib/perl5/5.8.0/x86_64-linux-thread-multi/CORE"   mysql.c
Running Mkbootstrap for DBD::mysql ()
chmod 644 mysql.bs
rm -f blib/arch/auto/DBD/mysql/mysql.so
LD_RUN_PATH="" /usr/bin/perl myld cc  -shared -L/usr/local/lib64 dbdimp.o mysql.o  -o blib/arch/auto/DBD/mysql/mysql.so
chmod 755 blib/arch/auto/DBD/mysql/mysql.so
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/Mysql.3pm
Manifying blib/man3/DBD::mysql::INSTALL.3pm
Manifying blib/man3/Bundle::DBD::mysql.3pm
mysqldev@melody:~/test/dbd-mysql> PERL_DL_NONLAZY=1 /usr/bin/perl "-MExtUtils::Command::MM" "-e" "test_harness(0, 'blib/lib', 'blib/arch')" t/00base.t
t/00base....install_driver(mysql) failed: Can't load '/home/mysqldev/test/dbd-mysql/blib/arch/auto/DBD/mysql/mysql.so' for module DBD::mysql: /home/mysqldev/test/dbd-mysql/blib/arch/auto/DBD/mysql/mysql.so: undefined symbol: net_buffer_length at /usr/lib/perl5/5.8.0/x86_64-linux-thread-multi/DynaLoader.pm line 229.
 at (eval 1) line 3
Compilation failed in require at (eval 1) line 3.
Perhaps a required shared library or dll isn't installed where expected
 at t/00base.t line 38
        Test returned status 255 (wstat 65280, 0xff00)
DIED. FAILED tests 4-5
        Failed 2/5 tests, 60.00% okay
Failed Test Stat Wstat Total Fail  Failed  List of Failed
t/00base.t   255 65280     5    2  40.00%  4-5
Failed 1/1 test scripts, 0.00% okay. 2/5 subtests failed, 60.00% okay.
[3 Sep 2004 22:58] Patrick Galbraith
I have tested this and now verified that this problem does indeed exist with both 4.0.21 and 4.1.4. The only fix I found was to compile DBD::mysql against libmysql dynamic libs. I have even tried compiling MySQL with -fPIC and still the problem exists. The solution therefore, is to compile DBD::mysql against libmysql dynamically:

(this is how I did it)
perl Makefile.PL --libs="-L/home/mysqldev/test/mysql/lib -lmysqlclient" --cflags="-I/home/mysqldev/test/mysql/include" --testuser=root

This resulted in both a successful compile as well as a successful 'make test'

Note: You shouldn't have to specify libs or cflags if you are installing this as root.