- How do I install a .so file? — newbie
- 3 Answers 3
- You must log in to answer this question.
- Linked
- Related
- Hot Network Questions
- Subscribe to RSS
- LiveInternetLiveInternet
- —Ссылки
- —Видео
- —Фотоальбом
- —неизвестно
- —Поиск по дневнику
- —Подписка по e-mail
- —Интересы
- —Друзья
- —Постоянные читатели
- —Сообщества
- —Статистика
- Как включить или зарегистрировать библиотеку в ОС linux
- How can I «register» my library libfoo.so to link it with `-lfoo`?
- 1 Answer 1
- LD_LIBRARY_PATH
- rpath
- ldconfig
How do I install a .so file? — newbie
I downloaded freeverb.tar.gz which contains a plugin library (freeverb.so) for Audacity. I extracted the .tar.gz file to my downloads folder but I don’t know what to do next. There is no Readme file or any other info contained in the .tar.gz file, just freeverb.so Can you advise me how to get the freeverb.so installed into the correct folder for Audacity to pick it up?
3 Answers 3
ldconfig creates, updates, and removes the necessary links and cache (for use by the run-time linker, ld.so) 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 (/usr/lib and /lib).
So, assuming that freeverb.so is located in /home/yourUser/Download directory (folder), create folder in your home:
mkdir /home/yourUser/myLibrary
and copy freeVerb.so library:
cp /home/yourUser/Download/freeverb.so /home/yourUser/myLibrary
create a simple file freeverb.conf like this:
echo "/home/yourUser/myLibrary" > freeverb.conf
Add you configuration file freeverb.conf in /etc/ld.so.conf.d directory (in this directory you can find files as example)
sudo cp freeverb.conf /etc/ld.so.conf.d
Run ldconfig in order to configure dynamic linker run-time bindings.
If /etc/ld.so.conf.d doesn’t exists, you can add your path at the end of /etc/ld.so.conf file.
At the end, if all went well, you can remove unnecessary file:
rm freeverb.conf rm /home/yourUser/Download/freeverb.so
Hi Letizia thank you for answering my question. This is how far I have got — I created freeverb.conf file in text editor containing the path to my freeverb.so file but when I try to save it to /etc/ld.so.conf.d directory I get error message ‘Do not have permission to save to /etc/ld.so.conf.d directory’ when I use UI. Could you tell me please what is the sudo command I need to use in the command line to add this file? I know this is basic but I have only come over from Windows and this is all new to me, many thanks, Dave
Hi Letizia,dt@laptop:~$ sudo cp freeverb.conf /etc/ld.so.conf.d [sudo] password for dt: cp: cannot stat `freeverb.conf’: No such file or directory
Hi Letizia, removed unnecessary freeverb.so file, I now somehow have a locked freeverb.so directory within my Home directory, I tried to remove it with -r /home/user/freeverb.so but I get error message ‘-r : command not found I also tried -R and —r
The simple approach is to put the file in /usr/local/lib , chown the file to root:root , and chmod it to 755 .
However, managing system files manually is not something I would personally recommend, so if possible I would search for a prebuilt .deb file for your particular version of Ubuntu.
You can install the package containing the library in a clean system (such as reference docker container with the same system) and then copy the missing shared library (as reported during failed run attempts) from the installed location (such as /lib/x86_64-linux-gnu/ ) to exactly the same location in the target system or container.
Be warned that multiple additional packages may need to be installed to extract all the necessary dependencies (a common problem with so-called «distroless» containers). It is therefore best to list all dependencies using ldd to avoid an iterative process.
You must log in to answer this question.
Linked
Related
Hot Network Questions
Subscribe to RSS
To subscribe to this RSS feed, copy and paste this URL into your RSS reader.
Site design / logo © 2023 Stack Exchange Inc; user contributions licensed under CC BY-SA . rev 2023.7.14.43533
Ubuntu and the circle of friends logo are trade marks of Canonical Limited and are used under licence.
By clicking “Accept all cookies”, you agree Stack Exchange can store cookies on your device and disclose information in accordance with our Cookie Policy.
LiveInternetLiveInternet
Блокнот ( Notepad): полезные функции Блокнот (англ. Notepad) — простой текстов.
1) нигде 2) blog.ru знает, наверное 3) нельзя 4) нельзя Здесь находятся вопросы
О ЛЮБВИ . О совсем другой любви знаете ли вы? О любви, в которой чудо просыпается внутри.
ВСЕ о тегах и оформлении постов Элементарные формы оформления .
советы по ЛиРу Что делать, если забыли пароль? Общие вопросы Что та.
—Ссылки
—Видео
Я специалист 06.06.2019 —> Смотрели: 7 (0) Ночь 05.03.2019 —> Смотрели: 0 (0) Приветствие 14.04.2015 —> Смотрели: 0 (0) Хочу сказать 14.04.2015 —> Смотрели: 0 (0) Моя линия жизни 23.01.2013 —> Смотрели: 350 (0)
—Фотоальбом
2019 06:33 15.09.2019 Фотографий: 21 2018 06:46 01.10.2018 Фотографий: 10 2017 09:10 24.05.2017 Фотографий: 5
—неизвестно
—Поиск по дневнику
—Подписка по e-mail
—Интересы
—Друзья
—Постоянные читатели
—Сообщества
—Статистика
Как включить или зарегистрировать библиотеку в ОС linux
1. Каталог, где регистрируются библиотеки /etc/ld.so.conf.d
Зарегистрировать одиночную динамическую библиотеку можно командой.
sudo xed /etc/ld.so.conf.d/libc.conf;
Надо прописать путь до библиотеки, примерно так.
/home/libd2
2. Файл для регистрации нового каталога, или файл с прописаными директориями библиотек, или файл с прописаными директориями вместе с библиотекой /etc/ld.so.conf
Редактируем файл.
sudo xed /etc/ld.so.conf;
Писать в файле надо примерно так.
include /hom/lib2/libz1.conf
3. После регистрации надо обновить кэш с помощью команды
Регистрировать и копировать библиотеки надо осторожно, потому что после ввода этой команды, любая не совместимость новых библиотек с операционной системой, приведет к зависанию компьютера навсегда и тогда придется переустанавливать linux, это в свою очередь приведет к удаленнию данны, программ скаченых из интернета.
4. Перезапустить компьютер.
How can I «register» my library libfoo.so to link it with `-lfoo`?
The application is the linker, normallt called ld . You «register» your library with ld by placing it in the default search place, usually /usr/lib . Otherwise you need to pass a -L argument.
1 Answer 1
If your library is not in a «standard» library directory such as (eg. /usr/local/lib or /usr/lib ) then you’ll need to tell the compiler it’s location -L when you link it -l :
$ gcc -L/home/username/foo -Wall -o test main.c -lfoo | | |__ location of libfoo.so or libfoo.a |__ link libfoo.so or libfoo.a
GCC assumes that all libraries start with ‘lib’ and end with .so or .a (.so is for shared object or shared libraries, and .a is for archive, or statically linked libraries).
- -L is the location to search for libraries linked to your executable
- -l links the library to the executable ( -lfoo can be translated as «link library libfoo.so»)
When using shared libraries sometimes simply linking them is not enough (eg. if the library is not installed in a standard location such as the example shown above). This is where using LD_LIBRARY_PATH , rpath or ldconfig comes into play. Static library paths won’t need to be set like shared libraries since they are compiled with the executable.
LD_LIBRARY_PATH
$ export LD_LIBRARY_PATH=/home/username/foo:$LD_LIBRARY_PATH
Exporting this variable informs the run-time linker to look in the specified location for the libfoo.so library that’s associated with the executable. LD_LIBRARY_PATH is more or less a temporary, or convenient way of setting a library’s location.
rpath
$ gcc -L/home/username/foo -Wl,-rpath=/home/username/foo -Wall -o test main.c -lfoo
rpath works similarly to LD_LIBRARY_PATH (as libraries can reside almost anywhere in userland), however, rpath is linked to the executable at compile time, and sets a «fixed» library location.
ldconfig
Ultimately what might be the best solution is to use ldconfig , which creates the necessary links and cache to the most recent shared libraries found in the standard library locations and ones you can specify. It does require elevated permissions (eg. sudo ) to set paths up this way, and should be used with a certain degree of caution.
$ sudo cp /home/username/foo/libfoo.so /usr/local/lib $ sudo chmod 0755 /usr/local/lib/libfoo.so
This copies the library into /usr/local/lib with permissions set to be readable by everyone.
$ sudo ldconfig $ ldconfig -p | grep foo libfoo.so (libc6) => /usr/local/lib/libfoo.so
Then we update the loader cache, and verify the path is set correctly.
$ gcc -Wall -o test main.c -lfoo
By using ldconfig , the -L option, LD_LIBRARY_PATH or rpath now shouldn’t be needed.