- /usr/lib или /usr/local/lib ?
- /usr/lib или /usr/local/lib ?
- /usr/lib или /usr/local/lib ?
- /usr/lib или /usr/local/lib ?
- /usr/lib или /usr/local/lib ?
- /usr/lib или /usr/local/lib ?
- Re: /usr/lib или /usr/local/lib ?
- /usr/lib или /usr/local/lib ?
- /usr/lib или /usr/local/lib ?
- /usr/lib или /usr/local/lib ?
- /usr/lib или /usr/local/lib ?
- /usr/lib или /usr/local/lib ?
- /usr/lib или /usr/local/lib ?
- /usr/lib или /usr/local/lib ?
- Библиотеки в / usr / local / lib не найдены
- Решение
- Libraries in /usr/local/lib not found
- 1 Answer 1
- What is the equivalent of /usr/lib/ on Windows?
- 1 Answer 1
- cannot find library under /usr/local/lib
- 1 Answer 1
/usr/lib или /usr/local/lib ?
Есть библиотеки, установленные из репозиториев, они располодены в /usr/lib. Я собирал эти же библиотеки, не удаляя репозиториевские, они располагаются в /usr/local/lib.
Собственно вопрос. Программы, которые используют эти библиотеки, которые из них будут использовать, те что расположены в /usr/lib или те что в /usr/local/lib?
/usr/lib или /usr/local/lib ?
2. cat /etc/ld.so.conf
/usr/lib или /usr/local/lib ?
ldd для интересующих программ указывает на /usr/lib.
# Multiarch support
/lib/i486-linux-gnu
/usr/lib/i486-linux-gnu
/usr/lib/alsa-lib
# libc default configuration
/usr/local/lib
man ld.so почитал немного. 🙁
В крайнем случае я могу заменить библиотеки в /usr/lib на симлинки на соответствующие библиотеки в /usr/local/lib, но вопрос в том, обязательно ли, я надеюсь что используются именно библиотеки в /usr/local/lib.
/usr/lib или /usr/local/lib ?
Имхо проще всего пересобрать нужные библиотеки через сорцовые пакеты.
/usr/lib или /usr/local/lib ?
Если вы говорите про пакеты исходников, что лежат в репозитории (ubuntu), то не то. Мне нужны немного другие версии (собственно, речь идёт об aotuv, а в репозитории устаревший libvorbis).
/usr/lib или /usr/local/lib ?
Короче, пересобрал нафиг с ./configure —prefix=/usr
Re: /usr/lib или /usr/local/lib ?
вот так убунта превращается в слакварь =)
/usr/lib или /usr/local/lib ?
ну а взять сорцевые пакеты из того репозитария, где подходящая версия? И пересобрать в .deb?
/usr/lib или /usr/local/lib ?
Подходящей версии в репах нет. Есть пара PPA с версией aotuv 5.5. Версия 5.7 же лежит только на оффсайте в архиве(ну и бинарники для форточек).
/usr/lib или /usr/local/lib ?
используются библиотеки найденные в том порядке, в котором они перечисленны в /etc/ld.so.conf
/usr/lib
/lib
автоматом добавляется в конец списка, если не было указано вручную
исключением может быть когда приложение имеет жестко вкомпилированый rpath, тогда вначале будут грузиться библиотеки из rpath , потом уже из ld.so.conf
тут уже написали, что проверить можно с помощью ldd
/usr/lib или /usr/local/lib ?
еще ремарка по убунте (и вообще любому дистрибутиву с пакетной системой) и ручной инсталляцией, раз уж make install совсем не избежать, то ставить нужно в /usr/local , это стандартный префикс , но пакеты туда не ставятся, т.е. он специально для разведения помойки локально.
ps: *bsd это не касается
pps: гента со своей revdep-rebuild таки не игнорирует /usr/local , а настойчиво возмущается если найдет там что постороннее
/usr/lib или /usr/local/lib ?
да, ещё важный момент — ldconfig, надо делать каждый раз после установки новой либы если make install это забыл или копировал вручную.
/usr/lib или /usr/local/lib ?
/usr/lib или /usr/local/lib ?
специально для плохо воспитанного анонимуса —
/opt/ / — префиксы для установки проприетарного ПО через разного рода инсталляторы
/usr/local — в линукс этому префиксу как раз и отведена роль локальной помойки, а удалять установленный через make install софт всегда было проблематично, особенно если make uninstall не сделать
и перед тем как хамить в след.раз , чтобы совсем не позориться, почитайте спеки на назначение различных каталогов в линукс.
Библиотеки в / usr / local / lib не найдены
Я строю приложение, используя платформу под названием ohNet .
После сборки фреймворка, есть возможность установить фреймворк через make install , По умолчанию библиотеки установлены внутри /usr/local/[lib|include] папки. Хорошо.
Я использую затмение для развития. Для того, чтобы использовать эти библиотеки, я должен установить путь включения к библиотеке (в этом случае usr/local/include/ohNet ), установите путь поиска компоновщика (-L) ( /usr/local/lib/ohNet ) и конкретные библиотеки (-l) (в этом случае я выбираю библиотеку с именем libohNet.so который является в этой папке.
Когда я строю проект в Eclipse, он работает нормально, однако, если я пытаюсь запустить программу, я сталкиваюсь со следующим сообщением:
Я дважды проверил это, и файл libohNet.so находится в этом каталоге!
По какой причине этот файл не может быть найден?
Я искал в Google и нашел несколько сообщений, говоря, что это проблематично, что библиотеки устанавливаются в /usr/local/lib вместо /usr/lib посмотреть здесь …
Нужно ли настраивать некоторые дополнительные параметры в eclipse делать ld распознавать библиотеки по этому пути? Какое решение для этого?
Решение
Это ошибка времени выполнения, а не ошибка сборки. Настройка -L Флаг ничего не делает для компоновщика времени выполнения. Что вам нужно сделать, так это сказать загрузчику среды выполнения, что он также ищет в / usr / local / lib библиотеки. Вы можете сделать это двумя способами. Во-первых, добавить путь к LD_LIBRARY_PATH переменная окружения:
Второе — обновить файл конфигурации компоновщика времени выполнения. Это может произойти либо в файле /etc/ld.so.conf, добавив строку:
где-нибудь в этом файле или путем создания нового файла * .conf в каталоге /etc/ld.so.conf.d/, который содержит новый путь. Например:
в этом. Это рекомендуемый способ сделать это, поскольку он позволяет вам отделить пути к вашим собственным библиотекам от путей, установленных системой. (Префикс «99» используется для того, чтобы убедиться, что файл загружен последним по сравнению с другими файлами в нем, так что он не будет вытеснять системные пути, которые могут содержать те же библиотеки.)
После того, как вы измените / создадите файл в / etc, вам нужно запустить:
как корень, чтобы изменения вступили в силу. (Эта команда обновляет файл /etc/ld.so.cache, который является фактическим файлом, используемым компоновщиком среды выполнения.)
Есть также другой способ для бинарного поиска необходимых библиотек во время выполнения. Вы можете жестко закодировать пути к библиотекам в самом исполняемом файле. Это достигается установкой так называемого «rpath». Это опция компоновщика, и она должна быть передана из компилятора gcc (или g ++), поэтому -Wl опция должна быть использована. Опция компоновщика -rpath=PATH , Так что вам нужно добавить это к вашей ссылке флаги:
Я не рекомендую это для вашего случая, хотя. Rpath полезен, когда вы отправляете библиотеки вместе с исполняемым файлом (может быть, с помощью установщика) и относительным rpath (используя rpath $ORIGIN feature) или абсолютный (например, при установке в / opt) затем используется для поиска этих связанных библиотек во время выполнения.
Libraries in /usr/local/lib not found
I am building an application using a framework called ohNet. After building the framework, there is the possibility to install the framework via make install . By default the libraries are installed inside the /usr/local/[lib|include] folders. ok.
I am using eclipse for development. In order to use this libraries I have to set the include path to the library (in this case usr/local/include/ohNet ), set the Linker search path (-L)( /usr/local/lib/ohNet ) and specific libraries (-l) (in this case i choose a library called libohNet.so which is in this folder. When I build the project in eclipse it works fine, however if i try to run the programm i am faced with the following message:
I’ve double checked this, and the file libohNet.so is in this directory! What’s the reason that this file cannot be found?
I searched on google and found some posts, saying that it is problematic that libraries are getting installed into /usr/local/lib instead of /usr/lib see here . Do I have to configure some additional settings in eclipse to make ld recognize libraries in this path? What’s the solution for this?
1 Answer 1
This is a runtime error, not a build error. Setting the -L flag does nothing for the runtime linker. What you need to do is to tell the runtime loader to also look in /usr/local/lib for libraries. You can do that in two ways. The first is to add the path to the LD_LIBRARY_PATH environment variable:
The second is to update the configuration file of the runtime linker. This can happen either in the /etc/ld.so.conf file, by putting the line:
somewhere in that file, or by creating a new *.conf file in the /etc/ld.so.conf.d/ directory that contains the new path. For example:
in it. This is the recommended way of doing this, as it allows you to keep your custom library paths separate from paths set by the system. (The «99» prefix is there to make sure the file is loaded last compared to other files there, so that it won’t preempt system paths that could contain the same libraries.)
After you modify/create the file in /etc, you need to run:
as root for the change to take effect. (This command updates the /etc/ld.so.cache file, which is the actual file used by the runtime linker.)
There’s also another way for a binary to find needed libraries at runtime. You can actually hard-code library paths into the executable itself. This is accomplished by setting a so called «rpath». This is a linker option and must be passed from gcc (or g++) to the linker, so the -Wl option has to be used. The linker option is -rpath=PATH . So you would need to add this to your link flags:
I don’t recommend this for your case though. An rpath is useful when you’re shipping libraries together with your executable (maybe with an installer), and a relative rpath (using the rpath $ORIGIN feature) or absolute one (for when you install in /opt, for example) is then used to find those bundled libs at runtime.
What is the equivalent of /usr/lib/ on Windows?
I am creating a cross-platform program that depends on libxml2. I do not want to use a POSIX environment such as Cygwin or MSYS on the Windows port of the app. I am planning to create a system of build scripts using Javascript Host for Windows and nmake. But, the question arose of where the build system should look for libxml2. In what locations should it look when the user does not specify a location? On Linux, it is usually /usr/lib/ and /usr/local/lib/. But on Windows, the only place that comes to mind is C:\Windows\system32. But isn’t that directory only modified by the system? (I obviously know next to nothing about the internals of Windows)
1 Answer 1
The true equivalent of /usr/lib/ in Windows really is %windir%\system32 , as it is always the (last) place where Windows looks for DLLs.
But simply dumping your libraries there is part of why DLL Hell is a thing. This is why the COM system was introduced; if your DLL is a «server module» for COM classes, you can register it (for instance through the regsvr32 utility), after which applications can dynamically link with its served classes through the CoCreateInstance() function. Here, the registry serves the purpose of /usr/lib/ , but is completely different.
In modern Windows versions, the need for explicit registration is no longer needed with (registration-free) side-by-side assemblies. In fact, explicit deregistration of assemblies is sometimes needed to play nice with this new system. In this sense, %SystemRoot%\winsxs is the equivalent of /usr/lib/ , but in an even more convoluted way.
Because of this mess, the answer to your underlying question — «where should I look for libxml2 ?» — is that «you won’t find it». Unlike the operating systems that were made for modularity, you usually don’t install separate libraries on Windows. If you want to build against libxml2 , you either bundle the .lib file with your source, or tell the user to provide it. If you want to deploy a build, you deploy libxml2 along with your application (either statically linked, or as a DLL inside the application directory).
And even if it were installed system-wide, since libxml2 isn’t made with Windows-specific concepts in mind, the only place to find it would be %windir%\system32 . Nobody has the gall to place it there, though.
Note: I’m not very well versed in COM and .NET, so the above might not be completely accurate. If someone wants to improve upon this answer, I’m open to turning this into a community wiki.
cannot find library under /usr/local/lib
when I use CMakeLists.txt with:
then i can find a library under /usr/local/lib,and make the C++ programe right and got the right result.
but when i replace it with:
then i got the error message:
why cmake do not link /usr/local/lib by default? did i do something wrong?
— add by aijinsong Oct 7, 2018 6:37 AM
i’m in more confused. when the CMakeLists.txt was:
the compiler can find cryptopp/sha.h. but when the CMakeLists.txt was:
the error message was:
when the CMakeLists.txt was:
the error message was still:
why i use cryptopp that the cmake ask me to link with library Boost::thread? i’m in more confused.
— add by aijinsong Oct 7, 2018 11:56 AM
And if i use g++ main.cpp -o main -lcryptopp , i can get the right result. This shows that the library cryptopp has been installed correcttly, and g++ can find the library. why when i do it by make, it can’t find the library?
— add for KamilCuk start
— add by aijinsong at Oct 7, 2018 3:27 PM
when i make it by make VERBOSE=1, i got the following message:
cd /Users/aijinsong/Documents/projects/com.aijs.cxx/bolochain/src && /usr/local/Cellar/cmake/3.12.3/bin/cmake -E cmake_link_script CMakeFiles/bolochain.dir/link.txt —verbose=1
and the text in link.txt is: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ -g -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk -Wl,-search_paths_first -Wl,-headerpad_max_install_names CMakeFiles/bolochain.dir/main.cpp.o -o bolochain /usr/local/lib/libboost_thread-mt.dylib -lcryptopp /usr/local/lib/libboost_chrono-mt.dylib /usr/local/lib/libboost_system-mt.dylib /usr/local/lib/libboost_date_time-mt.dylib /usr/local/lib/libboost_atomic-mt.dylib
this command cause the failure link but when i edit it like following, then c++ link command process very well: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ -g -Wl,-search_paths_first -Wl,-headerpad_max_install_names CMakeFiles/bolochain.dir/main.cpp.o -o bolochain /usr/local/lib/libboost_thread-mt.dylib -lcryptopp /usr/local/lib/libboost_chrono-mt.dylib /usr/local/lib/libboost_system-mt.dylib /usr/local/lib/libboost_date_time-mt.dylib /usr/local/lib/libboost_atomic-mt.dylib
just delete: -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk
I’m still working on this problem.
— add for KamilCuk end
1 Answer 1
Fist, Thanks @Kamil Cuk. The argument -VERBOSE=1 was so useful that I can get more detail messages that show me what happens when I use make.
The point is that when I use cmake under OSX system. It will generate a txt be named ‘link.txt’ which includes commands and part of it is as the following: -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk
when I delete this part, the commands will execute right. but when I add this line, the commands execute wrong. so the point is that this line maybe limited the search path of c++. Thanks @tsyvarev . You are right, -isysroot limited the c++ linkers searches /usr/local/lib .
Second, I did’t find out how to remove the line -isysroot . generated by OSX cmake. So, I need to find another solution.
When I search more information about find_package/include_directories/target_link_libraries, I found out that find_package need a FindXXX.cmake file to help it to find out the header file and libraries of the target. So I googled a FindCyptoPP.cmake file. and in this file it find out tow vars, one hold the value of cryptopp’s header directory path, and one hold the value of cryptopp’s library path. Then I use include_directories/target_link_libraries as following, the problem war solved.
and then when I use make -VERBOSE = 1 , I fond that the output was a little different when I use the CMakeLists.txt as following:
When I use three lines, the output contains a line /usr/local/lib/libcryptopp.dylib . When I use one line, the output contains a line -lcryptopp .
So, with the command line -isysroot , the command line -lcryptopp will search library under the directory defined by -isysroot , and under the directory, there is no library named cryptopp but under /usr/local/lib . But with command line /usr/local/lib/libcryptopp.dylib , it gaves the absolute path of the library, so the linkes just do the linking task and need not search. Thanks @Kamil Cuk again.
Thrid, I knew include_directories/target_link_libraries are two separate steps which one is used for include header file and one is used for link libraries.
Still, there were some problems not soled: — how to remove -isysroot? — how to create a FindXXX.cmake file? — how to make /usr/local/lib as a default search directory and was it a practice way to do so?
I will continue working on them, and come back a few days or weeks later.