Jump to content
  • Advertisement
Sign in to follow this  
Rectangle

Static libs without runtime dlls?

This topic is 2217 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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)?

Share this post


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

Share this post


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

Share this post


Link to post
Share on other sites
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)

Share this post


Link to post
Share on other sites
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. Edited by Rectangle

Share this post


Link to post
Share on other sites
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)

Share this post


Link to post
Share on other sites
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. Edited by Hodgman

Share this post


Link to post
Share on other sites

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! =)

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!