LD_PRELOAD Small hacks with LD_PRELOAD Build the corresponding dynamic library, and then execute your code with: LD_PRELOAD=/path/to/library/file.so /path/to/executable/exec_file