Include and Lib

Started by
2 comments, last by ravengangrel 14 years, 11 months ago
Hey guys, me again. I realise this may be a ridiculous question, but I've never really thought about it until now. Let's start with a little context. I have a project where I have used the MySQL development files so that's the Include and Lib files. I have also used a library (MySQL++), again Include and Lib files. When compiling the entire project, what's the difference? It's confused me a little bit, because I already have a mysql and mysql++ dll that links with the executable. I'm just not 100% on the difference between include and lib files. My idea, at the moment is that the include files are necessary to avoid compile time errors (header not found etc) and when the files are being linked together the linker uses the lib files to link everything together. Hopefully, I'm on the right lines somewhat. Cheers guys. Ray
Advertisement
Quote:Original post by raydey
My idea, at the moment is that the include files are necessary to avoid compile time errors (header not found etc) and when the files are being linked together the linker uses the lib files to link everything together.

Yup, that's pretty much right. The header files just say "Hey, these things exist, this is what they're named, and this is what they look like," but it doesn't tell the compiler what those things actually are. Rather, the lib files contain the actual definition, which the linker then uses to complete the building process of your program. Without the headers, the compiler doesn't know what things should look like or what to expect, and without the lib files the linker wouldn't have any actual definitions it could use.
[size=2][ I was ninja'd 71 times before I stopped counting a long time ago ] [ f.k.a. MikeTacular ] [ My Blog ] [ SWFer: Gaplessly looped MP3s in your Flash games ]
Cheers mate, that helped a lot :)
Indeed, the lib files are like a compiled replacement for the source (.c/.cpp) files.
So you can replace the lib with the source files which generated it. It's usually not a good idea, though, but I think it's something worth of knowing.

This topic is closed to new replies.

Advertisement