How to build a shared library (.so) without hardcoded full dependency paths?

前端 未结 6 1605
面向向阳花
面向向阳花 2020-12-29 07:37

I need to build two 3rd party shared libraries, so their .so files will be reused by other projects. However, after build one of these libraries contains hardcoded path to a

6条回答
  •  灰色年华
    2020-12-29 08:05

    I just got caught out thinking I had the same problem. None of the above answers helped me. Whenever I tried

    ldd libB.so 
    

    I would get in the output:

    libA.so.1 => /home/me/localpath/lib/libA.so.1.0
    

    and so I thought I had a hardcoded path. Turns out that I had forgotten I had LD_LIBRARY_PATH set for local testing. Clearing LD_LIBRARY_PATH meant that ldd found the correct installed library in /usr/lib/

提交回复
热议问题