gcc -shared libMySharedLibrary.so `ls *.o` The *.o files must be compiled with -fPIC or -fpic option.