Nice programing

/ usr / local / lib에서 공유 라이브러리를 검색합니까?

nicepro 2021. 1. 6. 20:47
반응형

/ usr / local / lib에서 공유 라이브러리를 검색합니까?


되어 /usr/local/lib공유 라이브러리를 검색? 이 오류가 있습니다.

[Leo@chessman ~]$ whereis ffmpeg
ffmpeg: /usr/local/bin/ffmpeg
[Leo@chessman ~]$ ffmpeg
ffmpeg: error while loading shared libraries: libavcore.so.0: cannot open shared object file: No such file or directory
[Leo@chessman ~]$ ls /usr/local/lib/libav*
/usr/local/lib/libavcodec.a            /usr/local/lib/libavfilter.a
/usr/local/lib/libavcodec.so           /usr/local/lib/libavfilter.so
/usr/local/lib/libavcodec.so.52        /usr/local/lib/libavfilter.so.1
/usr/local/lib/libavcodec.so.52.108.0  /usr/local/lib/libavfilter.so.1.74.0
/usr/local/lib/libavcore.a             /usr/local/lib/libavformat.a
/usr/local/lib/libavcore.so            /usr/local/lib/libavformat.so
/usr/local/lib/libavcore.so.0          /usr/local/lib/libavformat.so.52
/usr/local/lib/libavcore.so.0.16.1     /usr/local/lib/libavformat.so.52.94.0
/usr/local/lib/libavdevice.a           /usr/local/lib/libavutil.a
/usr/local/lib/libavdevice.so          /usr/local/lib/libavutil.so
/usr/local/lib/libavdevice.so.52       /usr/local/lib/libavutil.so.50
/usr/local/lib/libavdevice.so.52.2.3   /usr/local/lib/libavutil.so.50.36.0
[Leo@chessman ~]$ 

LD_LIBRARY_PATH검색하려는 모든 디렉토리를 포함하도록 설정되어 있는지 확인한 다음 다시 테스트하십시오.

다음을 사용하여이를 빠르게 테스트 할 수 있습니다.

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

해당 호출에 대해서만 설정됩니다.

또는 /etc/ld.so.conf검색된 기본 디렉토리를 포함하는 편집 할 수 있습니다 . 일부 Linux 배포판은 /usr/local/lib해당 파일에 포함되지 않을 수 있습니다.

루트로 또는을 사용 /etc/ld.so.cache하여 실행 하여 캐시를 업데이트해야 할 수도 있습니다 .ldconfigsudo


에서 http://tldp.org/HOWTO/Program-Library-HOWTO/shared-libraries.html :

GNU 표준은 소스 코드를 배포 할 때 기본적으로 모든 라이브러리를 / usr / local / lib에 설치하도록 권장합니다 (모든 명령은 / usr / local / bin에 있어야 함).

...

검색 할 디렉토리 목록은 /etc/ld.so.conf 파일에 저장됩니다. 대부분의 Red Hat 파생 배포판은 일반적으로 /etc/ld.so.conf 파일에 / usr / local / lib를 포함하지 않습니다. 나는 이것을 버그라고 생각하고 /etc/ld.so.conf에 / usr / local / lib를 추가하는 것은 Red Hat 파생 시스템에서 많은 프로그램을 실행하는 데 필요한 일반적인``수정 ''입니다.

데비안은 /etc/ld.so.conf포함 include /etc/ld.so.conf.d/*.conf하고 /etc/ld.so.conf.d/libc.conf포함

# libc default configuration
/usr/local/lib

예 그리고 아니오

프로그램은 라이브러리를 찾을 수있는 위치에 대한 컴파일 된 (ok, "linked-in") 아이디어를 가지고 있습니다. 프로그램이 lib를 찾을 것으로 예상하면 /usr/local/lib그렇게됩니다.

이라는 프로그램도 ldconfig및라는 구성 파일 /etc/ld.so.conf일 가능성과 /etc/ld.so.conf.d,이 사이트 특정 디렉토리를 지정하는 데 사용됩니다.

환경 변수와 같은 다른 노브를 나열하는 "man ld.so"를 읽으십시오 LD_LIBRARY_PATH.

LD.SO(8)                   Linux Programmer’s Manual                  LD.SO(8)

NAME
       ld.so, ld-linux.so* - dynamic linker/loader

DESCRIPTION
       The  programs ld.so and ld-linux.so* find and load the shared libraries
       needed by a program, prepare the program to run, and then run it.
. . .

...과...

LDCONFIG(8)                Linux Programmer’s Manual               LDCONFIG(8)

NAME
       /sbin/ldconfig - configure dynamic linker run time bindings

SYNOPSIS
       /sbin/ldconfig  [  -nNvXV ] [ -f conf ] [ -C cache ] [ -r root ] direc-
       tory ...
       /sbin/ldconfig -l [ -v ] library ...
       /sbin/ldconfig -p

DESCRIPTION
       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).  The cache is used by the run-time linker, ld.so or ld-
       linux.so.  ldconfig checks the header and filenames of the libraries it
       encounters  when  determining  which  versions  should have their links
       updated.
. . .

IIRC, ld.so는 /etc/ld.so.conf 파일을 사용하여 공유 객체를 검색 할 디렉토리를 나열합니다. 환경 변수를 사용할 수도 있습니다 LD_LIBRARY_PATH.

Linux의 ELF 헤더에는 RPATH 항목이 포함될 수도 있습니다. RPATH 항목을 확인하려면 다음을 실행하십시오.

readelf -d ffmpeg | grep RPATH

아마 이것으로부터 어떤 결과도 얻지 못할 것입니다. 컴파일하는 동안 RPATH를 설정하려면 다음을 수행하십시오.

gcc ... -wl, -rpath=MY_PATH

실행 디렉토리를 사용하려면 \$ORIGIN

chrpath와 같은 일부 프로그램에서는 기존 바이너리의 RPATH를 편집 할 수 있습니다.

참고 : setuid 인 프로그램 LD_LIBRARY_PATH은 보안 위험이 있으므로 사용하지 않습니다 .


find / -name 'libavdevice.so.*' to find out whether this library is available.

sudo gedit /etc/ld.so.conf

Add these lines and save:

include /usr/local/lib
include /usr

ldconfig


Another option for this old question is to use LD_RUN_PATH.

export LD_RUN_PATH=/usr/local/lib

Then compile again:

make
make install
ldconfig

Better than using LD_LIBRARY_PATH. Original reference from @cweiske linuxmafia.com/faq/Admin/ld-lib-path.html

ReferenceURL : https://stackoverflow.com/questions/4743233/is-usr-local-lib-searched-for-shared-libraries

반응형