Issue
My c++ Application has a single executable and multiple local shared libraries. When I build the executable, the linker(LD) sets the executable RPATH to the path of local shared libraries in the compilation environment.
The problem is that when I build a RPM of the application and install the RPM on other system, the application executable looks for the local shared libraries on the directory in which they were present in the compilation environment.
I want my executable to look for local shared libraries on the path on which they are installed by the RPM, rather than the path on which they were present during the time of compilation.
I know I can change the RPATH of my executable once I have installed the RPM using utility chrpath. But I want to automate it. What is the preferred way to do it.Whether through LD flag in Makefile, or by executing CHRPATH from the RPM spec file. or is there any other better way.
Solution
rpath is a linker flag and is probably set in LDFLAGS. To remove it simply edit the linker flags in your Makefile. Or if they are passed in to your build environment in an ambiguous way (they are set before calling make and you are not sure where) you can simply overwrite them:
LDFLAGS = -your_linker_flags
Hope this helps
Answered By - Pandrei Answer Checked By - Katrina (WPSolving Volunteer)