How to link a specific version of a shared library in makefile without using LD_LIBRARY_PATH?

前端 未结 2 1912
面向向阳花
面向向阳花 2020-12-16 20:28

I know that LD_LIBRARY_PATH is evil and it\'s a good habit to avoid using it. I have a program called server.c on a remote Solaris 9 server that holds two versi

2条回答
  •  佛祖请我去吃肉
    2020-12-16 21:05

    I figured out that I can include the absolute path of the specific library that I want to link to and it worked fine for me:

    LD = ${RPATH} -lsocket -lnsl -lpthread ${OPENSSLDIR}/lib/libssl.so.1.0.0 \
             ${OPENSSLDIR}/lib/libcrypto.so.1.0.0
    

    If you are using g++, Piotr Lesnicki pointed out that -l:libssl.so.1.0.0 also works. See more at the original post.

提交回复
热议问题