Mayank Kaushik <mayank.utexas@xxxxxxxxx> writes: > gcc -Wall -W -fPIC -shared -o library.so test.c -lc -Wl,-e,my_main This is a workable approach, but my_main must act as the entry point of the program. The entry point is not called with argc and argv. Take a look at crt1.o on your system to see what the entry point must do. > gcc -fPIC -fPIE -pie -o library.so test.c That does not make a shared library. > This can read arguments fine, but dlsym() fails: > > ./library.so: undefined symbol: my_func You can probably fix that problem by linking with -rdynamic. Perhaps we should ask: why do you want an executable shared library? Ian