Static libs without runtime dlls?

Started by
6 comments, last by Rectangle 11 years, 7 months ago
It was to my understanding that a static library is meant to eliminate the need for an external DLL at runtime, but for some reason when I run my project it still complains that it can't find glut32.dll. I checked the paths in the property pages, and can confirm that I am properly linking to glut32.lib, so why would I still need the DLL? Is there some kind of precompiler flag that I would need to set (in either my project, or while building glut32.lib)?
Advertisement
There are two type of .lib files - one is static libraries. All the code is contained in the lib file itself. Other type of .lib files are dll import libraries. They only specify that functions named A, B and C are found in XYZ.dll file.

glut32.lib is dll import library - it lists all the glut functions that are found in glut32.dll file. When you are linking to glut32.lib file then your final executable will need glut32.dll file at runtime.
Okay. So is it possible to build it as a static lib for win32? I can't find anything about it in the docs. All I can find are failed/unanswered attempts on StackOverflow.
I'm assuming it would'nt be as easy as switching to General->Configuration Type->Static library (.lib) in VC's project settings.
I think you need to add some GLUT_STATIC preprocessor directive somewhere in the settings? (edit:or maybe it was glew, cant really remember... anyways, there tends to be one or more of:
-Use a different library to link (static version)
-Fancy preprocessor directive
-Some init/uninit function calls only required for one way of linking)

o3o

Thanks, I'll give it a test later today and report my findings. For now I'm just including the dll with my app, but for deployment purposes this won't do.
On Linux *.a is static and *.so is a shared lib, I forgot the endings on Windows.

If I remember correctly glut is lgpl licenced, hence if you statically link you're whole app must be lgpl. (but not for dynamic linking)
The original GLUT library is closed source, so can't be rebuilt as a static lib.

There's a newer open-source replacement known as FreeGLUT, licensed under an MIT-style license, which is very permissive.
@Rectangle - are you using FreeGLUT?
I'm assuming it would'nt be as easy as switching to General->Configuration Type->Static library (.lib) in VC's project settings.
On MSVC, that is how you choose whether you're building a static-lib or a DLL biggrin.png
In the general case, that's all that's required, but as mentioned above, some libraries do things differently depending on how they're going to be built, so there might be some library specific macros that need to be defined as well.

The original GLUT library is closed source, so can't be rebuilt as a static lib.
There's a newer open-source replacement known as FreeGLUT, licensed under an MIT-style license, which is very permissive.

Thanks, built without a single issue! =)

This topic is closed to new replies.

Advertisement