Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why do we need *.lib files? [closed]

I don't seem to understand the need of *.lib files. Let's say I have 3 *.c files:

module1.c
module2.c
module3.c
myheaders.c

In each .c file we have 2 functions. Now if I call function x in module3.c from module1.c, module1.c knows about function x by looking in myheaders.c.

So if I compile this in VS I get a shiny little portable *.exe with no *.lib file attached, so why and when does one need *.lib files?

like image 374
defoe Avatar asked Dec 28 '13 19:12

defoe


2 Answers

*.lib files are for other programmers who want to use your functions in their own programs.

*.exe files are for end users who just want to run your program.

like image 142
Code-Apprentice Avatar answered Sep 26 '22 16:09

Code-Apprentice


Libraries can be made from groups of related functions that have been tested. They allow you to reuse code without having to go through the compilation stage each time.

Dynamic or Shared libraries allow you to upgrade parts of your executable without recompiling the executable or altering it.

In larger projects, validation of a program is a large portion of the schedule. Libraries that have already been tested will shorten the schedule and make everybody happy.

like image 41
Thomas Matthews Avatar answered Sep 23 '22 16:09

Thomas Matthews