This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

nrfjprog on Linux: support for LD_LIBRARY_PATH broken from 10.5.0 onwards and `/opt/SEGGER/JLink` hardcoded instead

Up to and including `v10.4.0`, `nrfjprog` correctly implements support for runtime `LD_LIBRARY_PATH`:

~/test$ # unpack directories
~/test$ tar -xf nRFCommandLineTools1040Linuxamd64tar.gz
~/test$ tar -xf nRF-Command-Line-Tools_10_4_0_Linux-amd64.tar.gz
~/test$ tar -xf JLink_Linux_V650b_x86_64.tgz
~/test$ mv nrfjprog nrfjprog_10_4_0

~/test$ # expected failure: no way to locate JLink libraries
~/test$ nrfjprog_10_4_0/nrfjprog --version
ERROR: JLinkARM DLL not found. Please reinstall latest JLinkARM.

~/test$ # expected success: library path provided explicitly
~/test$ LD_LIBRARY_PATH=$(realpath ./JLink_Linux_V650b_x86_64) nrfjprog_10_4_0/nrfjprog --version
nrfjprog version: 10.4.0 
JLinkARM.dll version: 6.50b

Starting with `v10.5.0` this is broken, and `nrfjprog` expects JLink libraries to be only at `/opt/SEGGER/JLink`:

~/test$ # unpack directories
~/test$ tar -xf  nRFCommandLineTools1050Linuxamd64tar.gz
~/test$ tar -xf nRF-Command-Line-Tools_10_5_0_Linux-amd64.tar.gz
~/test$ tar -xf JLink_Linux_V654c_x86_64.tgz
~/test$ mv nrfjprog nrfjprog_10_5_0

~/test$ # expected failure: no path JLink library
~/test$ nrfjprog_10_5_0/nrfjprog --version
ERROR: JLinkARM DLL not found. Please reinstall latest JLinkARM.

~/test$ # BUG: executable IGNORES provided LD_LIBRARY_PATH
~/test$ LD_LIBRARY_PATH=$(realpath JLink_Linux_V654c_x86_64) nrfjprog_10_5_0/nrfjprog --version
ERROR: JLinkARM DLL not found. Please reinstall latest JLinkARM.

~/test$ # BUG: it is UNACCEPTABLE to assume/force a fixed filesystem path
~/test$ sudo mkdir -p /opt/SEGGER
~/test$ sudo ln -s $(realpath JLink_Linux_V654c_x86_64) /opt/SEGGER/JLink
~/test$ nrfjprog_10_5_0/nrfjprog --version
nrfjprog version: 10.5.0 
JLinkARM.dll version: 6.50b

It is unacceptable to hardcode `/opt/SEGGER/JLink`.

Please revert to the behavior of `v10.4.0` (and previous) and correctly use the system linker RPATH resolution, which respects `LD_LIBRARY_PATH`.

Related