在Linux中与其他.so文件链接 [英] Linking with a different .so file in linux

查看:340
本文介绍了在Linux中与其他.so文件链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试编译具有标准构建过程的软件,例如

I'm trying to compile a piece of software which has the standard build process e.g.

configure
make
make install

该软件需要一个库,例如安装在/ usr / local / lib中的libreq.so。但是,我的问题是我想构建该软件并将其与我安装在/ home / user / mylibs中的同一库的另一个版本(我也有该库的源)链接起来。

The software requires a library e.g. libreq.so which is installed in /usr/local/lib. However, my problem is I'd like to build the software and link it with a different version of the same library (i have the source for the library as well) that I've installed in /home/user/mylibs.

我的问题是,如何针对/ home / user / mylibs中的库而不是/ usr / local / lib中的库编译和链接该软件

My question is, how do I compile and link the software against the library in /home/user/mylibs rather than the one in /usr/local/lib

我尝试将 LD_LIBRARY_PATH设置为包含/ home / user / mylibs,但这没有用。

I tried setting "LD_LIBRARY_PATH" to include /home/user/mylibs but that didn't work.

谢谢!

推荐答案

当您使用 autoconf 配置脚本时,请使用:

When you have an autoconf configure script, use:

CPPFLAGS=-I/home/user/include LDFLAGS=-L/home/user/mylibs ./configure ...

这会将指定目录添加到搜索标头的目录列表中(通常在使用库时是必需的) ,然后将另一个指定的目录添加到搜索实际库的列表中。

This adds the nominated directory to the list of directories searched for headers (usually necessary when you're using a library), and adds the other nominated directory to the list searched for actual libraries.

我一直使用它-在我的工作机上, / usr / local 由MIS进行维护,并且99.9%的时间包含过时的代码(并且是NFS挂载的,只读的),因此我很难避免使用它,并且在 / usr / gnu 下维护我自己的,最新的软件版本。它对我有用。

I use this all the time - on my work machine, /usr/local is 'maintained' by MIS and contains obsolete code 99.9% of the time (and is NFS-mounted, read-only), so I struggle to avoid using it at all and maintain my own, more nearly current, versions of the software under /usr/gnu. It works for me.

这篇关于在Linux中与其他.so文件链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆