链接到linux共享库

问题描述 投票:1回答:2

我正在尝试在Amazon Linux EC2实例上安装opendkim。从源代码编译时,我得到:配置:错误:未找到strlcpy / strlcat所以我从源代码安装了libbsd。安装完成后,我可以转到strlcat和strlcpy的手册页,但无法访问这些功能。我确认已安装共享库。 libbsd安装的输出声明使用4个选项之一:

If you ever happen to want to link against installed libraries in a given directory, LIBDIR, you must either use libtool, and specify the full pathname of the library, or use the `-LLIBDIR' flag during linking and do at least one of the following:

  - add LIBDIR to the `LD_LIBRARY_PATH' environment variable
     during execution
   - add LIBDIR to the `LD_RUN_PATH' environment variable
     during linking
   - use the `-Wl,-rpath -Wl,LIBDIR' linker flag
   - have your system administrator add LIBDIR to `/etc/ld.so.conf'

我跑了

export LD_RUN_PATH=/usr/local/lib
export LD_LIBRARY_PATH=/usr/local/lib/

另外,我的/etc/ld.so.conf包含

 include ld.so.conf.d/*.conf

和我的/etc/ld.so.conf.d/libbsd.conf包含

/usr/local/lib/libbsd

最后检查我的libbsd库nm -D /usr/local/lib/libbsd.so包含:

000000000000de30 T strlcat
000000000000ded0 T strlcpy

所以,我的问题是如何将strlcat和strlcpy暴露给命令行?或如何执行“使用`-Wl,-rpath -Wl,LIBDIR'链接器标志”选项,或者总的来说,链接共享库时我做错了什么?任何帮助表示赞赏。谢谢!

linux shared-libraries
2个回答
0
投票

所以以前无法链接到库,但是我能够解决依赖关系。 centos的二进制rpm完美安装:

sudo wget http://dl.fedoraproject.org/pub/epel/7/x86_64/l/libbsd-0.6.0-3.el7.x86_64.rpm
 sudo yum localinstall ./libbsd-0.6.0-3.el7.x86_64.rpm

sudo wget http://dl.fedoraproject.org/pub/epel/7/x86_64/l/libbsd-devel-0.6.0-3.el7.x86_64.rpm
sudo yum localinstall ./libbsd-devel-0.6.0-3.el7.x86_64.rpm

-1
投票

我在同一个问题上苦苦挣扎。显然,网络链接抛出了404。这里有任何帮助。

© www.soinside.com 2019 - 2024. All rights reserved.