How to use dylib in Mac OS X (C++)

前端 未结 4 611
日久生厌
日久生厌 2020-11-30 22:49

I made an application (an executable) calling some dylib successfully, However, the dylib files and the executable are in different directory. I added the directory contains

4条回答
  •  萌比男神i
    2020-11-30 23:43

    You need to set the DYLD_LIBRARY_PATH environment variable.

    From the dyld man page:

          This  is  a  colon  separated  list  of directories that contain libraries. The dynamic linker
          searches these directories before it searches the default locations for libraries.  It  allows
          you to test new versions of existing libraries.
    
          For  each  library  that  a program uses, the dynamic linker looks for it in each directory in
          DYLD_LIBRARY_PATH in turn. If it still can't find the library,  it  then  searches  DYLD_FALL-
          BACK_FRAMEWORK_PATH and DYLD_FALLBACK_LIBRARY_PATH in turn.
    

提交回复
热议问题