Creating your own library

Nov 8, 2010 at 5:15pm
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
Nov 8, 2010 at 5:26pm
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.
Nov 8, 2010 at 6:00pm
Or make a header-only library.
Nov 9, 2010 at 5:38am
thankyou... but i need a bit more explanation please.......
Nov 9, 2010 at 8:16am
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.

Nov 9, 2010 at 12:11pm
What kind of library would you like to create? Static (.lib) or dynamic(.dll).

Give us some info to help you more.
Nov 9, 2010 at 1:16pm
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.
Nov 9, 2010 at 1:44pm
closed account (1yR4jE8b)
I have a question too: What's the difference between a Static Library (.a) and an Object File (.o) ?
Nov 9, 2010 at 1:44pm
closed account (1yR4jE8b)
I have a question too: What's the difference between a Static Library (.a) and an Object File (.o) ?
Nov 9, 2010 at 2:09pm
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 Nov 9, 2010 at 5:12pm
Nov 9, 2010 at 4:40pm
still waiting for reply....how to create .lib file corresponding to .h file
Nov 9, 2010 at 5:01pm
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 Nov 9, 2010 at 5:04pm
Nov 9, 2010 at 5:05pm
@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 Nov 9, 2010 at 5:19pm
Topic archived. No new replies allowed.