How can I change the filename of a shared library after building a program that depends on it?

后端 未结 4 1551
情书的邮戳
情书的邮戳 2020-12-02 11:35

I have a program that depends on a shared library it expects to find deep inside a directory structure. I\'d like to move that shared library out and into a better place. On

4条回答
  •  再見小時候
    2020-12-02 12:26

    You can use LD_LIBRARY_PATH to change the search path for shared libraries. If your program depends on a particular relative path like your example shows, you will still need to have that directory structure. In other words you can move the lib from /home/user/dev/project/this/is/terrible/library.so to /usr/local/lib/this/is/terrible/library.so but not to /usr/local/lib/library.so

    If you can rebuild your program, then you can change the relative path it uses for the lib.

    There's some more info on shared libs in Linux at http://tldp.org/HOWTO/Program-Library-HOWTO/shared-libraries.html

提交回复
热议问题