That depends on your compiler and operating system but basically, you write your functions/methods for the library only and link with a special switch for creating a library.
Just like JoR said, it depends on your compiler and operating system. Do you mind mentioning what operating system you are working with so we could help you.
A static library is linked on compilation ( all the data of the library is merged in the final executable ) A dynamic library is linked on runtime ( there is one copy of the library available in the system and the running programs use it )
I read Shared Object instead of Object File. See Below
Bazzy: Static Libraries and object files are both for static linking/merge into the program at linking time. I don't know the exact difference but I think while a static library is structured in functions, an object file holds plain binary code so not necessarily functions.
mohitgoyal557: That wasn't exactly the question and usually .h files aren't meant to contain compiling code. Everything that can be said now is said: It depends on the enviorenment so Troubled646 should tell us his OS, compiler etc.