LD_LIBRARY_PATH:如何查找共享对象 [英] LD_LIBRARY_PATH : how to find a shared object

查看:68
本文介绍了LD_LIBRARY_PATH:如何查找共享对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个共享库(libxyz.so).给定LD_LIBRARY_PATH,如何找到此共享库的确切位置?如果我有一个依赖于此lib的二进制文件,那么我将在其上使用ldd.

I have a shared object ( libxyz.so ). Given LD_LIBRARY_PATH, how can find the exact location of this shared object? If i had a binary that depends on this lib, i would have used ldd on that.

这是我问的原因:我有一个cgi脚本,当使用LD_LIBRARY_PATH设置为VALUE1时可以使用.路径设置为VALUE2时,它不起作用.我想找到VALUE1中的路径所指定的库的确切位置(请注意VALUE1几乎有20多个不同的位置)

Here is the reason why i ask: I have a cgi script which works when using LD_LIBRARY_PATH set to say VALUE1. It does not work when the path is set to VALUE2. I would like to find the exact location of the library as specified by the path in VALUE1 ( Note that VALUE1 has almost 20+ different locations )

平台:Linux

推荐答案

将此文件放置在文件中:

Put this in a file:

#!/bin/bash
IFS=:

for p in ${LD_LIBRARY_PATH}; do
    if [ -e ${p}/libxyz.so ]; then
        echo ${p}
    fi
done

并运行它.

这篇关于LD_LIBRARY_PATH:如何查找共享对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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