Linux error cannot open shared object file no such file or directory

Ошибка error while loading shared libraries

Новые и опытные пользователи Linux могут сталкиваться с ошибкой error loading shared libraries во время запуска программ, также с ней могут сталкиваться программисты и все желающие компилировать программное обеспечение в своей системе. Эта ошибка в дословном переводе означает что возникла проблема во время загрузки общей библиотеки. О том что такое библиотеки и зачем они нужны вы можете узнать из статьи библиотеки Linux.

В этой же статье мы рассмотрим что значит ошибка error while loading shared libraries более подробно, а главное, как ее решить.

Что означает error while loading shared libraries?

Даже если вы не компилируете свои программы, то вы можете увидеть ошибку error while loading shared libraries: имя_библиотеки: cannot open shared object file: No such file or directory достаточно часто во время установки новых программ не через пакетный менеджер или программ, предназначенных для другого дистрибутива. Как я уже говорил, она возникает потому, что система не может найти библиотеку.

А вот почему ее нельзя найти и загрузить, это уже интересно. Этому может быть несколько причин:

  • Библиотека не установлена в системе;
  • Библиотека установлена, но неизвестно куда;
  • Библиотека установлена правильно, но имеет не ту версию.

При решении проблемы мы будем руководствоваться именно этими причинами и пытаться их решить.

Как исправить ошибку?

1. Библиотека не установлена

Первый вариант, тут все понятно, библиотеки просто нет в системе, поэтому мы и получаем такую ошибку. Верный способ ее решения — просто найти пакет библиотеки с помощью пакетного менеджера и установить ее. Обычно, пакеты с библиотеками называются так же, как и сами библиотеки с префиксом lib.

Например, если нам не хватает библиотеки libfuse2.so, то мы можем найти ее в Ubuntu такой командой:

sudo apt search libfuse2

Затем осталось только установить ее:

sudo apt install libfuse2

Если перед вами стоит задача собрать программу из исходников, то вам понадобится не только установить саму библиотеку, но и заголовочные файлы для нее:

sudo apt install libfuse-dev

И так для любой библиотеки. Но это не всегда помогает.

2. Библиотека находится не в том каталоге

Бывает что библиотека установлена, мы установили ее или она поставлялась вместе с программой, но ошибка как была, так и есть. Причиной этому может быть то, что загрузчик Linux не может найти библиотеку.

Поиск библиотек выполняется по всех папках, которые указаны в конфигурационных файлах /etc/ld.conf.d/. По умолчанию, это такие каталоги, как /usr/lib, /lib, /usr/lib64, /lib64. Если библиотека установлена в другой каталог, то, возможно, это и есть причина проблемы.

Вы можете посмотреть какие библиотеки сейчас доступны загрузчику с помощью команды:

Найти, где находится ваша библиотека можно с помощью команды locate. Например, нас интересует библиотека librtfreader.so:

Теперь мы знаем, что она находится по адресу /opt/kingsoft/wps-office/office6/. А значит, для работы программы необходимо сделать чтобы загрузчик библиотек ее видел. Для этого можно добавить путь в один из файлов /etc/ld.so.conf.d/ или же в переменную LD_LIBRARY_PATH:

Опять же, так вы можете поставить с любой библиотекой, которая взывает ошибку. Еще один более простой метод — это просто создать символическую ссылку на нужную библиотеку в правильной папке:

ln -s /opt/kingsoft/wps-office/office6/librtfreader.so /usr/lib/librtfreader.so

3. Неверная версия библиотеки

Эта причина ошибки довольно часто встречается при использовании программ не для вашего дистрибутива. Каждая библиотека имеет дополнительную версию, так называемую ревизию, которая записывается после расширения .so. Например, libav.so.1. Так вот, номер версии меняется всякий раз, когда в библиотеку вносятся какие-либо исправления.

Читайте также:  Linux foreach line in file

Часто возникает ситуация, когда в одном дистрибутиве программа собирается с зависимостью от библиотеки, например, libc.so.1, а в другом есть только libc.so.2. Отличия в большинстве случаев здесь небольшие и программа могла бы работать на второй версии библиотеки. Поэтому мы можем просто создать символическую ссылку на нее.

Например, библиотеки libusb-1.0.so.1 нет. Но зато есть libusb-1.0.so.0.1, и мы можем ее использовать:

Для этого просто создаем символическую ссылку на библиотеку:

sudo ln -s /usr/lib/libusb-1.0.so.0.1 /usr/lib/libusb-1.0.so.1

В большинстве случаев программа не заметит подмены и будет работать, как и ожидалось. Также для решения этой проблемы можно попытаться найти нужную версию библиотеки в интернете для своей архитектуры и поместить ее в папку /usr/lib/ или /usr/lib64/. Но после этого желательно обновить кэш:

Выводы

В этой статье мы рассмотрели почему возникает ошибка Error while loading shared libraries, а также как ее решить. В большинстве случаев проблема решается довольно просто и вы получите работоспособную программу. Надеюсь, эта информация была полезной для вас.

Источник

Ubuntu 20.04: libssl.so.1.0.0: cannot open shared object file: No such file or directory

I have upgraded from Ubuntu 18.04 to 20.04. One application does not run any more with the error:

I have searched this forum and followed the advice and tried: sudo apt-get install libssl1.0.0:amd64 .

I also tried sudo apt install libssl1.1 , and I get:

So then I tried sudo apt —fix-broken install libssl1.1 , but I get:

I also tried ‘E: Unable to locate package libssl1.0’ and I get:

Finally I tried:

However, I still get the same error. Any ideas before I downgrade to Ubuntu 18.04?

6 Answers 6

I ran into the same issue I think (I had the same error message trying to launch RStudio after upgrading Ubuntu from 18.04 to 20.04). Here is what worked for me after reading the following page: https://packages.ubuntu.com/xenial/amd64/libssl1.0.0/download

  • Edit the source list sudo nano /etc/apt/sources.list to add the following line: deb http://security.ubuntu.com/ubuntu xenial-security main
  • Then sudo apt update and sudo apt install libssl1.0.0 .

I hope t works for you too.

I solved my problem with libssl1.0.0 like this:

I opened http://security.ubuntu.com/ubuntu/pool/main/o/openssl1.0/ in my browser and download last version of libssl1.0.0 for my system (for me it was libssl1.0.0_1.0.2n-1ubuntu5.6_amd64.deb) Then I just install it:

I was trying to install RStudio Server 1.4.1103 on Ubuntu 20.04 and had the » libssl1.0.0 problem» (Ubuntu 18.04+ uses libssl1.1 natively). I found the solution here and made some versions updatings. Check here for updatings.

Installing libssl1.0.0

Installing RStudio Server 1.4.1103

Finding my local IP (in my case 192.168.0.17)

Finally I opened Studio Server in my browser using http://192.168.0.17:8787/.

I use Debian Buster when I faced the issue like you. I resolved it by doing this:

First I see libssl1.0.0 is not in the Debian Buster APT Repository, it is replace by libssl1.1

Therefore, I add the Jessie APT repository to /etc/apt/source.list by run this command:

Paste the Jessie APT Repository: «deb http://security.debian.org/debian-security jessie/updates main»

Save and Exit (Ctrl + s && Ctrl + x) Run the update: sudo apt update Install the libssl1.0.0 package sudo apt install libssl1.0.0

Re-run rstudio, and it will run successfully.

Источник

dlopen failed: cannot open shared object file: No such file or directory

The problem is I use dlopen to load a library (the .so is written by me, it’s not a system library), but I got the error shown in the title.

  1. I have included dlfcn.h
  2. in compiler, I used the -ldl command
  3. What I want to load is just the source code folder, I tried to add -L. , but it did not work.

3 Answers 3

If the library you want to dlopen is not in the standard search path you have a number of options:

Specify the full path to the file in dlopen

Add the path to the library via LD_LIBRARY_PATH

use the ld -rpath option to add a library path to the application.

g++ -link stuff- -Wl,-rpath=/path/to/library/

Note that options 1 & 3 hardcode the library path into your application. -rpath does have an option to specify a relative path, i.e.

Читайте также:  Installing kde on windows

Will embed a relative path into the application.

The most brutal and effective way to find out where your code goes wrong is the following command which will activate the debugging mode for shared libraries and is documented here:

Then, you will be surprised that so much information pops up. Don’t worry, these information tells you which shared libraries the command you just typed needs and where to locate these needed libraries. For example, if you type reset , the screen will be reseted and then information about the shared libraries reset command needs will be printed.

Then, execute your «problematic» executable to see what’s going wrong.

PS.1 : According to your accepted mythagal’s solution :

Specify the full path to the file in dlopen

It seemed that even though you use absolute or relative path in the dlopen function, the directory not found error will still show up. I am using CentOS, and my Debian is also having this problem. So I think the first solution mythagal provide is wrong. You can verify that in the «debugging» mode I mentioned above.

PS.2: If you «install» or «compile» a shared library rather than install it through package manager, you MUST run sudo ldconfig /path/where/not/found/shared/library/reside to notify the system of the newly added shared library. For example :

To understand what’s going on here, please carefully read all the contents in the link above.

PS.3 : You can always use the command export LD_DEBUG=help , export LD_DEBUG=libs to figure out how -rpath or LD_LIBRARY_PATH solve your problem. You will love this debugging mode.

PS.4: A less brutal way to figure out what’s going wrong:

This command can tell you whether your shared library to be opened is located or not. Besides, there are so many ways to fix your problem and each way has its limitation and application. So I strongly suggested you read the link I provide you above and understand how to choose the way to solve your problem. After reading that, if you actually feel like being very «OK», you can also read this Better understanding Linux secondary dependencies solving with examples for deeper understanding.

Источник

Linux error while loading shared libraries: cannot open shared object file: No such file or directory

Program is part of the Xenomai test suite, cross-compiled from Linux PC into Linux+Xenomai ARM toolchain.

Edit: OK I didn’t notice the .1 at the end was part of the filename. What does that mean anyway?

19 Answers 19

Your library is a dynamic library. You need to tell the operating system where it can locate it at runtime.

To do so, we will need to do those easy steps:

(1 ) Find where the library is placed if you don’t know it.

(2) Check for the existence of the dynamic library path environment variable( LD_LIBRARY_PATH )

if there is nothing to be displayed, add a default path value (or not if you wish to)

(3) We add the desire path, export it and try the application.

Note that the path should be the directory where the path.so.something is. So if path.so.something is in /my_library/path.so.something it should be :

Here are a few solutions you can try:

ldconfig

As AbiusX pointed out: If you have just now installed the library, you may simply need to run ldconfig.

ldconfig creates the necessary links and cache to the most recent shared libraries found in the directories specified on the command line, in the file /etc/ld.so.conf, and in the trusted directories (/lib and /usr/lib).

Usually your package manager will take care of this when you install a new library, but not always, and it won’t hurt to run ldconfig even if that is not your issue.

Dev package or wrong version

If that doesn’t work, I would also check out Paul’s suggestion and look for a «-dev» version of the library. Many libraries are split into dev and non-dev packages. You can use this command to look for it:

Читайте также:  Native windows operating system

This can also help if you simply have the wrong version of the library installed. Some libraries are published in different versions simultaneously, for example, Python.

Library location

If you are sure that the right package is installed, and ldconfig didn’t find it, it may just be in a nonstandard directory. By default, ldconfig looks in /lib , /usr/lib , and directories listed in /etc/ld.so.conf and $LD_LIBRARY_PATH . If your library is somewhere else, you can either add the directory on its own line in /etc/ld.so.conf , append the library’s path to $LD_LIBRARY_PATH , or move the library into /usr/lib . Then run ldconfig .

To find out where the library is, try this:

(Replace libraryname with the name of your library)

If you go the $LD_LIBRARY_PATH route, you’ll want to put that into your

/.bashrc file so it will run every time you log in:

Update
While what I write below is true as a general answer about shared libraries, I think the most frequent cause of these sorts of message is because you’ve installed a package, but not installed the «-dev» version of that package.

Источник

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

Please suggest a solution for solving this issue?? While giving the command:

the error that occurred:

14 Answers 14

The minimum configuration to properly run sqlplus from the shell is to set ORACLE_HOME and LD_LIBRARY_PATH . For ease of use, you might want to set the PATH accordingly too.

Assuming you have unzipped the required archives in /opt/oracle/instantclient_11_1 :

I did solve this error by setting

yes, not only $ORACLE_HOME/lib but $ORACLE_HOME too.

You should already have all needed variables in /etc/profile.d/oracle.sh . Make sure you source it:

The file’s content looks like:

If you don’t have it, create it and source it.

PERMISSIONS: I want to stress the importance of permissions for «sqlplus».

For any «Other» UNIX user other than the Owner/Group to be able to run sqlplus and access an ORACLE database , read/execute permissions are required (rx) for these 4 directories :

$ORACLE_HOME/bin , $ORACLE_HOME/lib, $ORACLE_HOME/oracore, $ORACLE_HOME/sqlplus

Environment. Set those properly:

A. ORACLE_HOME (example: ORACLE_HOME=/u01/app/oranpgm/product/12.1.0/PRMNRDEV/ )

B. LD_LIBRARY_PATH (example: ORACLE_HOME=/u01/app/oranpgm/product/12.1.0/PRMNRDEV/lib )

I know it’s an old thread, but I got into this once again with Oracle 12c and LD_LIBRARY_PATH has been set correctly. I have used strace to see what exactly it was looking for and why it failed:

sqlplus tries to load this lib from different dirs, some didn’t exist in my install. Then it tried the one I already had on my LD_LIBRARY_PATH:

open(«/oracle/product/12.1.0/db_1/lib/libsqlplus.so», O_RDONLY) = -1 EACCES (Permission denied)

So in my case the lib had 740 permissions, and since my user wasn’t an owner or didn’t have oracle group assigned I couldn’t read it. So simple chmod +r helped.

You can try usage:

This problem are because oracleinstant client not configure shared library.

Could you please check if LD_LIBRARY_PATH points to the oracle libs

On Ubuntu Server 20.04 and using instant client version 19.10.0.0, I used alien to install the rpm package. I got this error when I just used the -i option. However when, I added -c I did not have this issue. from the man page for alien:

-c, —scripts
Try to convert the scripts that are meant to be run when the package is installed and removed. Use this with caution, because these scripts might be designed to work on a system unlike your own, and could cause problems. It is recommended that you examine the scripts by hand and check to see what they do before using this option.

So it seems the correct configuration (in 19c) or the environment variables (in earlier versions) are set in these scripts which are not generated unless you run alien like this. (Thanks @Christopher Jones for correcting me on this)

Источник

Оцените статью