Linux error while loading shared libraries no such file or directory

Error while loading shared libraries: ‘libpcre.so.0: cannot open shared object file: No such file or directory’

I got the same error, and I fixed the problem by running sudo ldconfig .

I had installed PCRE manually before passenger installation (trying to solve another error with that version of passenger) and got this error when tried to start nginx. «sudo ldconfig» helped me too. Thanks a lot!

Execute below command and restart server again.

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

The message means what it says. The nginx executable was compiled to expect the PCRE (Perl-compatible Regular Expression) shared library to be available somewhere on LD_LIBRARY_PATH or specified in /etc/ld.so.conf or whatever equivalent library-locating mechanisms apply to your operating system, and it cannot find the library.

You will need to install PCRE — or configure your environment so that nginx will look for the PCRE library where it is installed.

@redroot: In the short-term (to get it working) you can add the directory where PCRE is installed to the LD_LIBRARY_PATH environment variable and try running again. If that works, then you need to investigate /etc/ld.so.conf . If it doesn’t work, then you need to check whether Ruby is 32-bit and PCRE is 64-bit, or whether Ruby is 64-bit and PCRE is 32-bit. The mixture won’t work. If you have a mixture, reinstall the correct version (bittiness) of one of the products, but PCRE alone is simpler than Ruby plus its extensions. Use file and ldd to analyze binaries and shared libraries.

As a guy who is working through nginx builds, I’m finding the configure system a bit unflexible. For example, configuring with OpenSSL assumes you want linking to a shared object. Its appears impossible to force static linking to libssl and libcrypto when both the static archive and shared object are present. Careful placement of -Bstatic and -Bshared does not help.

It’s an old post, but hopefully might be useful for someone. I was trying to install/start up an older version of NGINX on Amazon-Linux 2 and encountered this error. NGINX is expecting libpcre.so.0 , but the library wasn’t available on Amazon-Linux 2.

  1. Searched for a later version of libpcre.so using find / -name libpcre.so*
  2. I found libpcre.so.1 symlinked to libpcre.so.1.2. 0 in /usr/lib64/
  3. I created a new symlink to libpcre.so.1.2.0 and named it libpcre.so.0 using ln -s libpcre.so.1.2.0 libpcre.so.0
  4. Restarted NGINX and it worked
Читайте также:  Arch linux no tty

There are few recommendations, with this I have solved the issue which I had.

  • As mentioned above add the lib path in the /etc/ld.so.conf and check the same is updated or not by using ldconfig -v
  • Add the LD_LIBRARY_PATH in the .bash_profile and refresh the same with . . bash profile .
  • If the lib file is not get updated then use the updatedb to refresh the library list.

I got the same error after I installed ClamAV, Antivirus for my Linux server.

[root@10 ~]# yum install clamav clamav-db clamd -y Loaded plugins: aliases, changelog, kabi, presto, product-id, refresh-packagekit, security, subscription-manager, tmprepo, verify, : versionlock This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register. Loading support for Red Hat kernel ABI Setting up Install Process Resolving Dependencies --> Running transaction check ---> Package clamav.x86_64 0:0.100.3-1.el6 will be installed --> Processing Dependency: libjson-c.so.2()(64bit) for package: clamav-0.100.3-1.el6.x86_64 ---> Package clamav-db.x86_64 0:0.100.3-1.el6 will be installed ---> Package clamd.x86_64 0:0.100.3-1.el6 will be installed --> Running transaction check ---> Package json-c.x86_64 0:0.11-13.el6 will be installed --> Finished Dependency Resolution Dependencies Resolved ==================================================================================================================================== Package Arch Version Repository Size ==================================================================================================================================== Installing: clamav x86_64 0.100.3-1.el6 base 1.3 M clamav-db x86_64 0.100.3-1.el6 base 150 M clamd x86_64 0.100.3-1.el6 base 243 k Installing for dependencies: json-c x86_64 0.11-13.el6 base 27 k Transaction Summary ==================================================================================================================================== Install 4 Package(s) Total download size: 152 M Installed size: 154 M Downloading Packages: Setting up and reading Presto delta metadata Processing delta metadata Package(s) data still to download: 152 M (1/4): clamav-0.100.3-1.el6.x86_64.rpm | 1.3 MB 00:00 (2/4): clamav-db-0.100.3-1.el6.x86_64.rpm | 150 MB 00:01 (3/4): clamd-0.100.3-1.el6.x86_64.rpm | 243 kB 00:00 (4/4): json-c-0.11-13.el6.x86_64.rpm | 27 kB 00:00 ------------------------------------------------------------------------------------------------------------------------------------ Total 100 MB/s | 152 MB 00:01 Running rpm_check_debug Running Transaction Test Transaction Test Succeeded Running Transaction Installing : json-c-0.11-13.el6.x86_64 1/4 /sbin/ldconfig: libraries libpcre.so.0 and libpcre.so.1 in directory /lib64 have same soname but different type. Installing : clamav-db-0.100.3-1.el6.x86_64 [############################# ] 2/4 Installing : clamav-db-0.100.3-1.el6.x86_64 2/4 Installing : clamav-0.100.3-1.el6.x86_64 3/4 Installing : clamd-0.100.3-1.el6.x86_64 4/4 Verifying : clamd-0.100.3-1.el6.x86_64 1/4 Verifying : clamav-0.100.3-1.el6.x86_64 2/4 Verifying : json-c-0.11-13.el6.x86_64 3/4 Verifying : clamav-db-0.100.3-1.el6.x86_64 4/4 Installed: clamav.x86_64 0:0.100.3-1.el6 clamav-db.x86_64 0:0.100.3-1.el6 clamd.x86_64 0:0.100.3-1.el6 Dependency Installed: json-c.x86_64 0:0.11-13.el6 Complete! [root@10 ~]# [root@10 ~]# grep: error while loading shared libraries: libpcre.so.0: wrong ELF class: ELFCLASS32 grep: error while loading shared libraries: libpcre.so.0: wrong ELF class: ELFCLASS32 [root@10 ~]# grep: error while loading shared libraries: libpcre.so.0: wrong ELF class: ELFCLASS32 

Later I found below libraries got deleted from /lib64

libjson-c.so.2.0.1 libjson.so.0.1.0 libpcre.so.0 -> libpcre.so.0.0.1 

I copied those from other server and uninstalled ClamAV.

Running Transaction Erasing : clamd-0.100.3-1.el6.x86_64 1/3 Erasing : clamav-0.100.3-1.el6.x86_64 2/3 warning: /etc/freshclam.conf saved as /etc/freshclam.conf.rpmsave Erasing : clamav-db-0.100.3-1.el6.x86_64 3/3 Verifying : clamd-0.100.3-1.el6.x86_64 1/3 Verifying : clamav-0.100.3-1.el6.x86_64 2/3 Verifying : clamav-db-0.100.3-1.el6.x86_64 3/3 Removed: clamav.x86_64 0:0.100.3-1.el6 clamav-db.x86_64 0:0.100.3-1.el6 clamd.x86_64 0:0.100.3-1.el6 Complete! 
sending incremental file list libjson-c.so.2.0.1 libjson.so.0.1.0 libpcre.so.0 -> libpcre.so.0.0.1 

Источник

Читайте также:  Dev null file linux

Ошибка 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 install libfuse2

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

sudo apt install libfuse-dev

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

Читайте также:  Установщик пакетов deb linux

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. Так вот, номер версии меняется всякий раз, когда в библиотеку вносятся какие-либо исправления.

Часто возникает ситуация, когда в одном дистрибутиве программа собирается с зависимостью от библиотеки, например, 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, а также как ее решить. В большинстве случаев проблема решается довольно просто и вы получите работоспособную программу. Надеюсь, эта информация была полезной для вас.

Обнаружили ошибку в тексте? Сообщите мне об этом. Выделите текст с ошибкой и нажмите Ctrl+Enter.

Источник

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