I believe what you want is to use the -c flag. What this does is basically allow you to compile an object file, without the need for a main function. You can then use this object file in any of your programs, you just need to include the header file, so your new objects can compile. They will then link to this .o file. You could also consider turning this into a .a file, but it is an unnecessary step. The only real difference between .a and .o files is how the data is stored, and the compilation commands that take advantage of them. This would be the typical series of commands for taking advantage of a .o file.
STEP1: First build the .o file, with the -c flag, which at the most basic level lets the compiler know that the lack of a main is okay.
COMMAND1: g++ -c someLib.cpp -o someLib.o
STEP2: Now combine the objects from our library and my cpp file that wants to use the "library" into the same program.
COMMAND2: g++ someMainFile.cpp someLib.o -o someMainProgram
The benefit of dynamic linking over this process would be that you don't have symbol duplication. In the case above the symbols that exist in someLib.o will also end up existing in someMainProgram (EX: if you compiled then deleted all occurances of someLib.o from your system, your program would still run!). If they were in a DLL, someMainProgram would only have the symbols in someMainFile.cpp, and it would attempt to find the symbols in someLib at run time, amongst the available dlls.