C++ 加载共享库时出错:libgsl.so.0:无法打开共享对象文件:没有这样的文件或目录

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/22222666/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-28 00:00:18  来源:igfitidea点击:

error while loading shared libraries: libgsl.so.0: cannot open shared object file: No such file or directory

c++gsl

提问by Abdolvahed

I use gsl. After I compiled my .cpp file and run it, I faced with below error:

我用gsl。在编译我的 .cpp 文件并运行它后,我遇到了以下错误:

error while loading shared libraries: libgsl.so.0: cannot open shared object file: No such file or directory

加载共享库时出错:libgsl.so.0:无法打开共享对象文件:没有这样的文件或目录

I found same as this problem in: https://groups.google.com/forum/#!topic/cortex_var/6vluX7pP0Sk& Linux error while loading shared libraries: cannot open shared object file: No such file or directory& http://www.gnu.org/software/gsl/manual/html_node/Shared-Libraries.html

我在以下位置发现与此问题相同的问题:https: //groups.google.com/forum/#!topic/ cortex_var/ 6vluX7pP0Sk& 加载共享库时出现 Linux 错误:无法打开共享对象文件:没有这样的文件或目录& http:// /www.gnu.org/software/gsl/manual/html_node/Shared-Libraries.html

And I have done as in the above links wrote but the error is still remained. Can anyone help me?

我已经按照上面的链接写了,但错误仍然存​​在。谁能帮我?

回答by Inquisitive

To make it work do the following steps

要使其工作,请执行以下步骤

Start Borne Shell

启动 Borne Shell

$LD_LIBRARY_PATH= path to your gsl lib folder inside the gsl installation folder
$export LD_LIBRARY_PATH

now run your executable

现在运行你的可执行文件

It should work fine.

它应该可以正常工作。

回答by ManuelAtWork

First, you need to locate the file (libgsl.so.0). You can do this, for example, by using the findcommand:

首先,您需要找到文件 (libgsl.so.0)。例如,您可以使用以下find命令执行此操作:

sudo find / -name "libgsl.so.0"

Let us assume, the file is located in /usr/local/lib. (If the file has not been found, install the corresponding package ordownload the source, build it and install it.) Now, you have two options:

让我们假设,该文件位于/usr/local/lib. (如果没有找到文件,安装相应的包或者下载源码,编译安装。)现在,你有两个选择:

(1) Quick & Dirty:

(1) 快速和肮脏:

LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib
export LD_LIBRARY_PATH

This adds the path of the library to an environment variable. The disadvantage of this option is, that it is only valid for the current session. It will not work for other users. It will not work once you log off and on again.

这会将库的路径添加到环境变量中。此选项的缺点是,它仅对当前会话有效。它不适用于其他用户。一旦您注销并再次登录,它将无法工作。

(2) Permanent:

(2) 永久:

Review your /etc/ld.so.conf. If /usr/local/libis not listed there, add it. Now, run ldconfigto detect the shared object file and add it to some system-wide index.

查看您的/etc/ld.so.conf. 如果/usr/local/lib未在此处列出,请添加它。现在,运行ldconfig以检测共享对象文件并将其添加到某个系统范围的索引中。

回答by ginkgo

In my experience, fastStructuredepends on gsl 1.6but not the latest version.

根据我的经验,fastStructure依赖于gsl 1.6而不是最新版本。

wget http://gnu.mirror.vexxhost.com/gsl/gsl-1.6.tar.gz
tar -zxvf gsl-1.6.tar.gz
cd gsl-1.16
./configure
make
sudo make install

Add these lines to your .bashrcfile on your home directory.

将这些行添加到您.bashrc的主目录中的文件中。

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib
export CFLAGS="-I/usr/local/include"
export LDFLAGS="-L/usr/local/lib"

then, run source ~/.bashrc to set these environment variables.

然后,运行 source ~/.bashrc 来设置这些环境变量。

It works fine when I change the version from the latest to the 1.6.

当我将版本从最新更改为 1.6 时,它工作正常。

回答by ahathoor

I got the same error with Krita on Arch Linux. I made a symlink with

我在 Arch Linux 上使用 Krita 时遇到了同样的错误。我做了一个符号链接

ln /usr/lib/libgsl.so /usr/lib/libgsl.so.0

and that fixed it.

并修复了它。

回答by user6206320

Have you tried updating your library? The program I was trying to run simply needed a newer version of gsl (I had 1.9.5 while it needed 2.0.0 or newer).

您是否尝试过更新您的图书馆?我试图运行的程序只需要更新版本的 gsl(我有 1.9.5,而它需要 2.0.0 或更新版本)。

If you are on arch you can run:

如果你在拱门上,你可以运行:

yaourt gsl

and select the appropriate one.

并选择合适的。

回答by Shicheng Guo

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/shg047/software/gsl/lib/

such as: to-mr: error while loading shared libraries: libgsl.so.19: cannot open shared object file: No such file or directory

如:to-mr: error while loading shared libraries: libgsl.so.19: cannot open shared object file: No such file or directory

回答by zmwang

You can use gsl-config --libsin you makefile or in the command line when you link the gsl library. Just type gsl-configyou can find the options it offers to you. Choose the options you need, you will find compile and link process much easier than before. As a result, when I type gsl-config --libsin my terminal, I get -L/usr/local/lib -lgsl -lgslcblas -lm. Although it is very simple, first you should know where you gsl is installed. You can add the directory to the PATHenvironment variable or use the absolute path to execute gsl-config.

gsl-config --libs当您链接 gsl 库时,您可以在 makefile 或命令行中使用。只需键入gsl-config您就可以找到它提供给您的选项。选择您需要的选项,您会发现编译和链接过程比以前容易得多。结果,当我gsl-config --libs在终端中输入时,我得到-L/usr/local/lib -lgsl -lgslcblas -lm. 虽然很简单,但首先你应该知道你的gsl安装在哪里。您可以将目录添加到PATH环境变量中或使用绝对路径执行gsl-config

回答by JoKalliauer

I needed libgsl.so.19:

我需要libgsl.so.19

/snap/inkscape/current/bin/inkscape: error while loading shared libraries: libgsl.so.19: cannot open shared object file: No such file or directory

/snap/inkscape/current/bin/inkscape: error while loading shared libraries: libgsl.so.19: cannot open shared object file: No such file or directory

I solved it with:

我用以下方法解决了它:

  1. Installing Anaconda
  2. searched for libgsl.so.19and found it in ~/anaconda3/lib
  3. run LD_LIBRARY_PATH=$LD_LIBRARY_PATH:~/anaconda3/lib(best add it to ~/.basrc)
  1. 安装蟒蛇
  2. libgsl.so.19在 ~/anaconda3/lib 中搜索并找到它
  3. 运行LD_LIBRARY_PATH=$LD_LIBRARY_PATH:~/anaconda3/lib(最好将它添加到 ~/.basrc