64bit linux系统安装DBD问题

结论就是:


mysql提供的静态库,没有加-fPIC选项,导致DBD编译失败


解决:

1. 加fPIC,重新编译libmysqlclient.a

2. 使用动态库


Description:
I am trying to compile the DBD::mysql perl module on an x86_64 platform and I get the
following errors:

[some stuff cut out here]

rm -f blib/arch/auto/DBD/mysql/mysql.so
LD_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_32
can not be used when making a shared object; recompile with -fPIC
/usr/local/mysql/lib/libmysqlclient.a: could not read symbols: Bad value
collect2: ld returned 1 exit status
chmod 755 blib/arch/auto/DBD/mysql/mysql.so
chmod: cannot access `blib/arch/auto/DBD/mysql/mysql.so': No such file or directory
make: *** [blib/arch/auto/DBD/mysql/mysql.so] Error 1

After 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 the
x86_64 platform (this is different from regular x86).  This allows other people to create
their own shared libraries from your static libraries by linking against them, which is
what DBD::mysql is trying to do with libmysqlclient.a.  I found this information at
http://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 around
listed (complile a dynamic libmysqlclient library and link against that instead).  I
believe that it is still a bug, however, because only a workaround is listed--the actual
fix 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 of
headaches 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 dynamic
libraries were provided with the binary distributions)

Suggested fix:
Begin compiling static libraries (specifically libmysqlclient.a) with -fPIC on the x86_64
platform or provide dynamic libraries in addition to the static libraries.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值