Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Must C libraries have .lib extension

Tags:

c

I don't know C, but need to interact with some C files in a project. I'm noticing that some files have .lib extension, while others (which are also supposed to be libraries) have .c and .h files only in a big folder.

  • What's the difference between these libraries.
  • Are the .c and .h folders also libraries.
  • Is the .lib format the official format for libraries and these guys who did .c and .h just lazy or not using best practice?
like image 401
sameold Avatar asked Nov 09 '11 23:11

sameold


1 Answers

.c and .h files are source code, i.e., text files. In order to "use" them (i.e., execute the code on a computer) you need to compile them into...

a .lib file is the end result, i.e., a binary file. It can be statically lined into another executable and the code run on a computer. This saves you the time of compiling the source if you don't need to.

.lib is just one common extension, but it doesn't really matter what the extension is as long as the file is valid. Point your compiler/linker to the .whatever library file and let 'er rip, it will all work out in the end.

like image 88
Ed S. Avatar answered Oct 12 '22 23:10

Ed S.