Sign in to follow this  

[Newbie-DevC++] Help! Why need glut32.dll if I use static lib?

This topic is 4351 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

Hi! I'm starting to study C++ mainly to learn openGL, so I'm a newbie in both cases :-) I use DevC++. I've found and compiled succefully various openGL examples. Before build the application, I link the project with static libs, like, in example, libglut32.a. The executables running fine, but if I try them on a system without glut32.dll, they don't start. I'm a bit confused about libraries: if I use static libs, all code should be included in final executable, right? ...so if I use libglut32.a, why is needed glut32.dll? I assume I'm compiling using static libs, because if I don't add the libglut.a to project, the compiler return a link error. Besides I don't see, in DevC++, an option like "compile using dynamic libs" and goggling, I've found an article that explain that, to use dynamic libs, it's needed a special code, like: HMODULE LoadLibrary(LPCSTR lpFileName); FARPROC GetProcAddress(HMODULE hModule, LPCSTR lpProcName); BOOL FreeLibrary(HMODULE hModule); etc... And lines like these are not in files I'm compiling... Please, help a poor newbie!!! thx, Zyx

Share this post


Link to post
Share on other sites
I'm not very familiar with DevC++ (I Use MSVisualStudio), but those *.a libs may be only the export libraries for the dll's. In VC++, if i want to use a dll statically (meaning i don't load it dynamically durring execution, but at the start of the application), I have to include some *.lib files (which are the same as static libs) in order the application to build. But they are not static libs, you still need the dlls, they are just some kind of interface between your app and the dlls. Just make sure the dlls that are reported missing are in one of your directories you've set in the IDE as executable directories.

Share this post


Link to post
Share on other sites
Yes, infact I know .a are the equivalent of .lib

But...so...what are static libs?
I thinked static was .lib (or .a) and dynamic was .dll ...

Now I'm totally confused...

thank for patience!

Share this post


Link to post
Share on other sites
Added:

I've found a definition of static libs:
---------------
Just a collection of pre-compiled material declared in the relevant
header files. Needed by the linker. Include into the project.
---------------

So I can compile separately various cpp files, that contains all functions definitions, to obtain various .o
Finally I compile all into a static lib, that is like "zipping" all .o in a compressed file.

So, the .a hasALL I NEED!
I've just try to compile a simple static lib and use it in a basic project...it work, without dll!

An example here:
http://www.crasseux.com/books/ctutorial/Building-a-library.html

but using DevC++ is more simple, just choose "static lib" in project option and compile it.
Later, make a new project that use some functions defined in lib, and compile it after added the lib to project...

Share this post


Link to post
Share on other sites
A .lib may either be a "true" static library, or simply the import library for a DLL. Instead of actually containing the code, the LIB functions load the DLL and call its functions. In many cases you can tell from the size of the file.

On POSIX systems, .a are static libraries and .so dynamic libraries. Dev-C++ inherits this notation. But the practices of the Win32 platform still seep in, and you may very well have a .a that is "merely" import library. If you want a libglut32.a that is guaranteed to be a static lib, you'll have to look harder, and possibly have to compile it yourself.

Share this post


Link to post
Share on other sites
I don't knwo if there is any tool for examining the libs. However, you can examine them from the header file to see what functions are in it. As Fruny said, there will be very hard to find an opengl static library. Almost all of them are .dlls, with import libraries. Its much more easy to work with them like that, instead of using static libraries. Just think that opengl32.dll contains your video card's opengl driver. So you can keep the application and replace the dll, you'll got new drivers with the same application, without need to recompile. But if you use your own static library, you'll have to recompile again your libraries. If you are using opengl, and you've included opengl32.lib (or what is your opengl library in devc++), you are already using the opengl32.dll. There is no real static library in this case. You don't get any error for that because the opengl32.dll is in the Windows\system32 folder, so your application finds it, but it doesn't find other dlls, the ones from your errors.

Share this post


Link to post
Share on other sites
Quote:
Original post by zyx
Exist a way to examine the lib? (I mean a compiled lib)
A tool? An utility... a special command?


If dev-cpp comes with tools, you might try ar -t library. If not, and IIRC, the MS library tool should be lib.exe -- see if you find it.

Share this post


Link to post
Share on other sites

This topic is 4351 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.

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