I am working on a project that requires wrapping libc calls particularly file i/o calls like open, read, write, close etc. I have created a shared library (say, wrapper.so) and preload this wrapper.so. I could successful use this wrapper on Linux by setting the LD_PRELOAD variable. On MAC, I tried setting the DYLD_FORCE_FLAT_NAMESPACE to 1, DYLD_INSERT_LIBRARIES to /path/wrapper.so using 1) .bash_profile, 2)launchctl setenv, 3)LaunchAgent, 4)LaunchDeamon approaches but nothing work.
I tried even setting the DYLD_FORCE_FLAT_NAMESPACE, DYLD_INSERT_LIBRARIES environment variables at application level for specific applications via their Info.plist but this didn't work either.
Note: I could set some random new variable, say MYVAR, with all the above mentioned approaches. So, it is while setting the DYLD_* variables that I have problem setting. Can you please help me set the DYLD_FORCE_FLAT_NAMESPACE, DYLD_INSERT_LIBRARIES variables on MAC.