Native Binaries: gcc and rpath $ORIGIN

I can’t seem to find a way to get -Wl,-rpath,'$ORIGIN' to get passed to the linker on linux builds. Or, rather, if it’s getting passed in, it doesn’t appear to be getting processed correctly because I’m not seeing an RPATH entry in the dynamic section of the elf executable, as determined from readelf.

This is how I’m setting the option in my build script:

cppCompiler.args '-Wl,-rpath,\'$ORIGIN\''

…and I can see the option listed apparently correctly in the options.txt file under the build file system:


…but when I run readelf -d <executable-name>, there is no RPATH entry to be found anywhere.

Anyone else had any luck with this linker option?

Hi, linker arguments can be adjusted by using

linker.args ...


cppCompiler.args '-O2'
linker.args '-s'

Gcc link options can be provided to the compiler using -Wl,<ld-option>[,<ld-option-value>]. At any rate, it doesn’t seem to matter whether I specify the options as compiler or linker args, the result is the same. There is no RPATH information getting placed in the executable.

Ah jeez - @marmax: your suggestion did the trick. When using linker.args previously, I was changing the args to match what the ld linker itself would expect (e.g. omitting the -Wl). Turns out all that was needed was to keep the args the same, but change cppCompiler to linker.