64-bit DBD installation in Linux

Source: Internet
Author: User

The conclusion is:

The static library provided by MySQL is not added with the-FPIC option, leading to DBD compilation failure.

Solution:

1. Add FPIC and re-compile libmysqlclient.

2. Use a dynamic library

Description:I am trying to compile the DBD::mysql perl module on an x86_64 platform and I get thefollowing errors:[some stuff cut out here]rm -f blib/arch/auto/DBD/mysql/mysql.soLD_RUN_PATH="/usr/lib" /usr/bin/perl myld cc  -shared -L/usr/local/lib dbdimp.o mysql.o -o blib/arch/auto/DBD/mysql/mysql.so     \   -L/usr/local/mysql/lib -lmysqlclient -lcrypt -lnsl -lm -lz   \   /usr/bin/ld: /usr/local/mysql/lib/libmysqlclient.a(libmysql.o): relocation R_X86_64_32can not be used when making a shared object; recompile with -fPIC/usr/local/mysql/lib/libmysqlclient.a: could not read symbols: Bad valuecollect2: ld returned 1 exit statuschmod 755 blib/arch/auto/DBD/mysql/mysql.sochmod: cannot access `blib/arch/auto/DBD/mysql/mysql.so': No such file or directorymake: *** [blib/arch/auto/DBD/mysql/mysql.so] Error 1After a couple of days of digging around, this is what I've found:1.  If only static libraries are provided, they should be compiled with -fPIC on thex86_64 platform (this is different from regular x86).  This allows other people to createtheir own shared libraries from your static libraries by linking against them, which iswhat DBD::mysql is trying to do with libmysqlclient.a.  I found this information athttp://www.x86-64.org/lists/discuss/msg05760.html -- even though it is not about mysql,it is about this specific linker error.2.  This same bug was filed under Mysql Bug #4670, which was closed with a work aroundlisted (complile a dynamic libmysqlclient library and link against that instead).  Ibelieve that it is still a bug, however, because only a workaround is listed--the actualfix would be to link all static libraries for x86_64 platforms with -fPIC.I will attempt to compile my own libmysqlclient with -fPIC, but it would save a lot ofheadaches for other people if they came compiled that way with the binary distributions.How to repeat:Try to compile DBD::mysql on an x86_64 platform with static mysql libraries (no dynamiclibraries were provided with the binary distributions)Suggested fix:Begin compiling static libraries (specifically libmysqlclient.a) with -fPIC on the x86_64platform or provide dynamic libraries in addition to the static libraries.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.