How to install RPATH in CMAKE?

I want to create and install the software locally in the path $HOME/.local/ instead of the system-wide folder /usr/ . The software uses CMAKE for compilation.

After installation, program files are executed in $HOME/.local/bin/ and libraries in $HOME/.local/lib/ . Thus, when I try to run the program, it throws an error that does not require a library, which, by the way, is present in $HOME/.local/lib/ ).

The program works fine if I set $LD_LIBRARY_PATH to $HOME/.local/lib . But I do not want this. Therefore, instead, I would like to know how to specify the RPATH variable (which will point to $HOME/.local/lib ) when compiling software using CMAKE.

Please help.

+5
source share
1 answer

I use the following two lines in CMakefile

 set(CMAKE_MACOSX_RPATH 1) set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib") 

(the first is only required if you are using MacOSX)

+6
source

Source: https://habr.com/ru/post/1267037/


All Articles