سؤال

I Have a LD_PRELOAD file. On what OS and conditions i should compile this preload to work on most systems (Unix/Linux). The most wanted are FreeBSD, Ubuntu, CenstOS, Solaris.

Thanks!

هل كانت مفيدة؟

المحلول

You need to compile it into a shared library. Here's how I typically compile mine:

libt.so: t.lo
        g++ -fPIC -O3 -W -Wall -shared -Wl,-export-dynamic -o $@ $^ -lc

t.lo: t.cc
        g++ -c -fPIC -O3 -W -Wall $^ -o $@

Then to use it, you add the library to the LD_PRELOAD environment variable before launching that file. If you do it this way from the bash command line:

LD_PRELOAD=libt.so executable_name -and args

then, it will only set it for that command line run, and not affect any other programs you launch afterwards.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top