如果 Perl 报告找不到 ../mysql/mysql.so 模块,则问题可能是 Perl 找不到 libmysqlclient.so 共享库。您应该能够通过以下方法之一解决此问题:If Perl reports that it cannot find the
../mysql/mysql.so module, the problem is
probably that Perl cannot locate the
libmysqlclient.so shared library. You should
be able to fix this problem by one of the following methods:
将
libmysqlclient.so复制到其他共享库所在的目录(可能是/usr/lib或/lib)。Copylibmysqlclient.soto the directory where your other shared libraries are located (probably/usr/libor/lib).修改
-L编译所用选项DBD::mysql实际位置libmysqlclient.so.Modify the-Loptions used to compileDBD::mysqlto reflect the actual location oflibmysqlclient.so.在 Linux 上,可以将
libmysqlclient.so所在目录的路径名添加到/etc/ld.so.conf文件中。On Linux, you can add the path name of the directory wherelibmysqlclient.sois located to the/etc/ld.so.conffile.将
libmysqlclient.so所在目录的路径名添加到LD_RUN_PATH环境变量中。有些系统使用LD_LIBRARY_PATH代替。 Add the path name of the directory wherelibmysqlclient.sois located to theLD_RUN_PATHenvironment variable. Some systems useLD_LIBRARY_PATHinstead.
请注意,如果链接器无法找到其他库,您可能还需要修改 -L 选项。例如,如果链接器无法找到 libc,因为它位于 /lib 中,并且链接命令指定了 -L/usr/lib,请将 -L 选项更改为 -L/lib 或将 -L/lib 添加到现有链接命令中。Note that you may also need to modify the -L
options if there are other libraries that the linker fails to
find. For example, if the linker cannot find
libc because it is in /lib
and the link command specifies -L/usr/lib, change
the -L option to -L/lib or add
-L/lib to the existing link command.
如果您得到出现 DBD::mysql 错误后,您可能正在使用 gcc (或使用使用 gcc 编译的旧二进制文件):If you get the following errors from
DBD::mysql, you are probably using
gcc (or using an old binary compiled with
gcc):
/usr/bin/perl: can't resolve symbol '__moddi3' /usr/bin/perl: can't resolve symbol '__divdi3'
添加 -L/usr/lib/gcc-lib/... -lgcc 到链接命令,当 mysql.so 库已构建(编译 Perl 客户端时,请检查 mysql.so 的 make 的输出)。 -L 选项应指定系统上 libgcc.a 所在目录的路径名。Add -L/usr/lib/gcc-lib/... -lgcc to the link
command when the mysql.so library gets built
(check the output from make for
mysql.so when you compile the Perl client).
The -L option should specify the path name of the
directory where libgcc.a is located on your
system.
导致此问题的另一个原因可能是 Perl 和 MySQL 不是都使用 gcc 编译的。在这种情况下,您可以通过使用 gcc 进行编译来解决不匹配问题。Another cause of this problem may be that Perl and MySQL are not both compiled with gcc. In this case, you can solve the mismatch by compiling both with gcc.