Creating your own library

can anyone tell me please how exactly we create our own library in c++? i want to use my own functions in other programs... thanku
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.
Or make a header-only library.
thankyou... but i need a bit more explanation please.......
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.

What kind of library would you like to create? Static (.lib) or dynamic(.dll).

Give us some info to help you more.
static libraries can also be .a (linux) .la (MinGW etc.)... And dynamic .dylib (Mac OS) .so (Linux) and so on. It really all depends on your OS.
closed account (1yR4jE8b)
I have a question too: What's the difference between a Static Library (.a) and an Object File (.o) ?
closed account (1yR4jE8b)
I have a question too: What's the difference between a Static Library (.a) and an Object File (.o) ?
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
Last edited on
still waiting for reply....how to create .lib file corresponding to .h file
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.
Last edited on
@mohitgoyal557
We are still waiting for more details:
JoR wrote:
That depends on your compiler and operating system
blackcoder41 wrote:
Just like JoR said, it depends on your compiler and operating system.


[Edit|correction of post above]
An object file is a compiled file, a static library may be made of many object files.
Last edited on
Topic archived. No new replies allowed.