After finishing with first one and compiling the second one (on Windows 7, CodeBlocks MinGW), I got surprised by very much increased size of the executable.
For both projects I am linking GLFW and GLEW dynamically, and also adding libopengl32.a
A size of 34 kb is quite trivial, so I'm not even sure why you're worrying about it.
The first thing I see is that the Glew library is actually being linked in the second example, whilst the compiler is optimizing it out in the first. While the headers were called in the first tutorial, the library wasn't actually being called, so the compiler didn't bother linking the library. However, now that the library is being called, the compiler couldn't get away with such an optimization.
Also, while a lot of code looks like it isn't being added, it is. For example, the LoadShader function that is called within the second example actually has its definition in a common folder, and as you can see, it isn't exactly small.
Another thing: Within that function, the standard library is being used quite a bit. With its generic template nature, it naturally generates a lot of code, so while it doesn't look like much, several hundred/thousands of lines are being generated behind the scenes. Take a peek at the vector header and string header. For every different type that is used in those classes, that same amount of code is generated. (There are plenty exceptions, but that's beyond the scope of what I'm willing to discuss right now, so that's just an elementary explanation. Take it with a grain of salt.) I imagine that that is a large factor as well.
Anyways, that's all I could gather within a few minutes of searching the code. I'm sure someone could point out more later on.
Another thing: Within that function, the standard library is being used quite a bit. With its generic template nature
Both sources are using pure C headers.
it naturally generates a lot of code, so while it doesn't look like much, several hundred/thousands of lines are being generated behind the scenes. Take a peek at the vector header and string header.
I have never measured it, but I wouldn't expect a template instance of std::vector to be larger that 1 KiB.
If a library is being linking statically, the linker may be able to remove functions that are unused in the first version. It may be the case that a single function causes a cascading effect, causing lots of other functions to get added to the final executable.
I linked both Glew and Glfw dynamically, at least I believe so! That's exactly what I was in doubt about after seeing 1 MB executable.
I added glew32.dll and glfw3.dll to project folder, and in linker settings added paths to glfw3dll.a and libglew32.dll.a.
This should be dynamically linked, right? Or is there another way for me to check also for future reference? :)