도전2022

so 파일 동작 원리 학습 본문

작업/리눅스

so 파일 동작 원리 학습

hotdigi 2010. 1. 21. 14:52
SMALL
Dynamically Linked "Shared Object" Libraries: (.so 파일) 이라고 한다. 
이제는 Shared Object 라고 해야 겠다. 

Library 관련된 문서가 많이 있다. 

- Program Library HOWTO(kr)
- Program Library HOWTO(en)
-pdf 파일
- GNU Libtool
- FHS : Filesystem Hierarchy Standard,
      각 폴더에 대한 Purpose, Requirements, Specific Options, 등이 있다. 


환경 설정 내용을 보면 
#cat /etc/ld.so.conf
 include /etc/ld.so.conf.d/*.conf

#ls /etc/ld.so.conf.d/
 i486-linux-gnu.conf  libasound2.conf  libc.conf

#cat /etc/ld.so.conf.d/i486-linux-gnu.conf
# Multiarch support
/lib/i486-linux-gnu
/usr/lib/i486-linux-gnu

#cat
/etc/ld.so.conf.d/libasound2.conf
/usr/lib/alsa-lib

#cat /etc/ld.so.conf.d/libc.conf
# libc default configuration
/usr/local/lib



Library Path:

In order for an executable to find the required libraries to link with during run time, one must configure the system so that the libraries can be found. Methods available: (Do at least one of the following)

  1. Add library directories to be included during dynamic linking to the file /etc/ld.so.conf

    Sample: /etc/ld.so.conf

    /usr/X11R6/lib
    /usr/lib
    ...
    ..
    /usr/lib/sane
    /usr/lib/mysql
    /opt/lib
                        
    Add the library path to this file and then execute the command (as root) ldconfig to configure the linker run-time bindings. 
    You can use the "-f file-name" flag to reference another configuration file if you are developing for different environments. 
    See man page for command ldconfig.

    OR

  2. Add specified directory to library cache: (as root) 
    ldconfig -n /opt/lib 
    Where /opt/lib is the directory containing your library libctest.so 
    (When developing and just adding your current directory: ldconfig -n . Link with -L.)

    This will NOT permanently configure the system to include this directory. The information will be lost upon system reboot.

    OR

  3. Specify the environment variable LD_LIBRARY_PATH to point to the directory paths containing the shared object library. This will specify to the run time loader that the library paths will be used during execution to resolve dependencies. 
    (Linux/Solaris: LD_LIBRARY_PATH, SGI: LD_LIBRARYN32_PATH, AIX: LIBPATH, Mac OS X: DYLD_LIBRARY_PATH, HP-UX:SHLIB_PATH)

    Example (bash shell): export LD_LIBRARY_PATH=/opt/lib:$LD_LIBRARY_PATH or add to your ~/.bashrc file:

    ...
    if [ -d /opt/lib ];
    then
       LD_LIBRARY_PATH=/opt/lib:$LD_LIBRARY_PATH
    fi
    
    ...
    
    export LD_LIBRARY_PATH
          

    This instructs the run time loader to look in the path described by the environment variable LD_LIBRARY_PATH, to resolve shared libraries. This will include the path /opt/lib.

Library paths used should conform to the "Linux Standard Base" directory structure.





LIST

'작업 > 리눅스' 카테고리의 다른 글

linux 웹 서버 만들기  (0) 2010.02.19
putty를 사용하자.  (0) 2010.02.19
DDD 사용하자.  (0) 2010.02.18
리눅스 커널 구하자.  (0) 2010.02.10
opensource 리눅스 게임 자료조사  (0) 2009.12.23