Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Fascinating.

Some useful stack overflow answers on this topic. First, the trick to get GCC to pass the ORIGIN option to the linker: -Wl,-z,origin.

Secondly, how to pass it as the rpath option:

"-Wl,-rpath,'$ORIGIN' -- note that you need quotes around it to avoid having the shell interpret it as a variable, and if you try to do this in a Makefile, you need $$ to avoid having make interpret the $ as well."

https://stackoverflow.com/questions/38058041/correct-usage-o...

The chrpath utility is also fascinating, as it allows you to rewrite the elf headers to change the rpath. Possibly better for installs than passing lots of env variables.

Various warnings on this topic to not use actual relative paths unless you really want that behaviour.



Consider applying for YC's Summer 2026 batch! Applications are open till May 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: