Libraries, dlls, and headers

Hello,

I've been programming for quite a while now, but I always have problems with 3rd party libraries and headers when I have to build them myself, I don't quite understand what is what.

I will explain with the latest trouble I've had. I built FTGL with visual studio and I linked the libraries in the project that I'm using. Now, how do I use them in my code? I need the FTGL header "ftgl.h", if I take the one from the packeage, which I built, it requires all the other header files from the source code to be included. So what is the point of the library if I include the entire source code? Is there another FTGL header that I'm supposed to use?

From what I've read, libraries are the code and headers are the definitions, mostly, so it would make sense to have a library and a header, which defines everything, so it can be used from the library.

And then there are dll files, where do they come in? There are dll and static libraries, dll libraries require dll files, so why do you need the library in the first place if the dll files contain the code? S, now the library contains the definitions?

And static libraries don't need dlls, because they contain all the code?


Could someone please explain, in detail, what libraries, dlls and headers are and how it all comes together. And building libraries and dlls aswell.
Or point me to the right literature please, it's hard to find quality and up to date literature.
So what is the point of the library if I include the entire source code?

You're not including the entire source code. You're including only the declarations for the functions and classes in the library / DLL.

There are dll and static libraries, dll libraries require dll files, so why do you need the library in the first place if the dll files contain the code?

The difference between static libraries and DLLs is when the code is linked. A static library is linked at the time you build your executable and is included in your executable image. A DLL is not linked when you build your executable and is not included in the executable image. Instead, the DLL is linked at the time you run the program. Other than the difference in when a library or DLL is loaded, they are pretty much the same.

DLLs are commonly used when code is shared among multiple executables. The OS only needs to keep one image of the DLL in memory regardless of how many programs are using it. Whereas with a static library, the static library will exist in memory in every executable with which it is bound.

Another advantage of DLLs is that a DLL can be replaced and you don't have to rebind your program. This is why third party libraries are usually released as DLLs. Simply replace the DLL and restart your program and you automatically get the new DLL.
Topic archived. No new replies allowed.