Sign in to follow this  
raydey

Include and Lib

Recommended Posts

raydey    159
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

Share this post


Link to post
Share on other sites
Cornstalks    7030
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.

Share this post


Link to post
Share on other sites
ravengangrel    406
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.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this