Creating dynamic libraries is rather like linking an executable, as the linker has to extract link information to allow the code to be loaded in during program execution. To create the library libMyLib.so from files a.o, b.o, c.o:-
g++ -shared -o libMyLib.so a.o b.o c.o
The -o identifies the following name as the output file.