# RUNPATH ignored by linker for ITK-libs of newer ITK (4.12.2)

**URL:** https://discourse.itk.org/t/runpath-ignored-by-linker-for-itk-libs-of-newer-itk-4-12-2/743
**Category:** Engineering
**Tags:** cmake
**Created:** [March 7, 2018, 12:55pm UTC](https://discourse.itk.org/t/runpath-ignored-by-linker-for-itk-libs-of-newer-itk-4-12-2/743 "2018-03-07T12:55:24Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![grothausmann.roman](https://discourse.itk.org/user_avatar/discourse.itk.org/grothausmann.roman/32/582_2.png) [@grothausmann.roman](https://discourse.itk.org/u/grothausmann.roman)
#### Post date: [March 7, 2018, 12:55pm UTC](https://discourse.itk.org/t/runpath-ignored-by-linker-for-itk-libs-of-newer-itk-4-12-2/743/1 "2018-03-07T12:55:25Z")

</div>

It seems programs compiled (cmake, make, gcc-6.3, debian-9) with newer ITK (e.g. 4.12.2) set the RUNPATH in an executable (with CMAKE\_INSTALL\_RPATH\_USE\_LINK\_PATH TRUE) whereas compiling the same code with older ITK (e.g. 4.9.1) sets the RPATH.  
This subtle difference seems to lead to the problem, that I get “error while loading shared libraries” when executing the installed program, even though `readelf -d /opt/ITK-CLIs/bin/hist | egrep 'RUNPATH|RPATH'` lists the correct RUNPATH. Starting the executable with LD\_LIBRARY\_PATH set to this RUNPATH lets the linker find the itk-libs, which makes me wonder whether the linker on my current system ignores the RUNPATH.  
What can I do about that despite setting LD\_LIBRARY\_PATH?  
How can I make the linker use RUNPATH or how can I compile with itk-4.12.2 such that RPATH is used instead?

---

<div class="post-metadata">

### Author: ![grothausmann.roman](https://discourse.itk.org/user_avatar/discourse.itk.org/grothausmann.roman/32/582_2.png) [@grothausmann.roman](https://discourse.itk.org/u/grothausmann.roman)
#### Post date: [March 7, 2018, 3:46pm UTC](https://discourse.itk.org/t/runpath-ignored-by-linker-for-itk-libs-of-newer-itk-4-12-2/743/2 "2018-03-07T15:46:21Z")

</div>

Configuring/compiling with `SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--disable-new-dtags")` makes programs linking to itk-4.12.2 use RPATH instead of RUNPATH. Running the installed executables then does not need LD\_LIBRARY\_PATH.  
What is the best practice to deal with this RUNPATH problem?
