Why LD_LIBRARY_PATH is BAD and the correct way to load dynamic libraries

前端 未结 2 1816
陌清茗
陌清茗 2021-02-02 14:21

So, I have a program that runs with OpenBlas and I want to compile it. The linking process looks like this:

gcc -o prog prog.o -O3 -I/opt/OpenBLAS/include -L/opt         


        
2条回答
  •  迷失自我
    2021-02-02 15:04

    Add the path to the runtime library search path.

    gcc -Wl,-rpath=/opt/OpenBlas/lib ...
    

    What the -L option does at link time, the -rpath option does at run time.

提交回复
热议问题