Reputation: 121
As per my understanding dlls are dynamically loaded at run time and static libraries(.lib files) are loaded during linking. I also have understood that there are two types of .lib files. One is static .lib files which means that during linking these files will be linked with the code that I have written. Another type of .lib files are simply import files, which merely tells the linker the path of the .dll files which may be in system32 or sysWoW64 folder. Is my understanding correct?
Now I have few doubts on how this whole system of .lib and .dll files work.
I have compile freeglut libraries and in the lib folder I have 3 important files. freeglut.lib, freeglut-static.lib and freeglut.dll. I am assuming that freeglut.lib is an import library because it is of only 36KB size. I am also assuming that freeglut-static.lib is a static library which has a size of about 2MB.
I can make my code work by placing freeglut.lib in C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Lib and freeglut.dll in sysWoW64 folder. This works for me and I understand this is the most efficient way.
When I am trying to use freeglut-static.lib it does not compile. I placed freeglut-static.lib in C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Lib(I deleted freeglut.lib from here) and added freeglut-static.lib in Project properties>linker>input>additional dependencies. however visual studio keeps on saying
'LINK : fatal error LNK1104: cannot open file 'freeglut.lib'
why is it so? This is just an attempt to learn about the libraries and I can continue working with the first method.Can someone give insight into this? Am I missing something?
Upvotes: 3
Views: 1623
Reputation:
I think that the header will try to use freeglut.lib either way. You have to specify that you like to use the static version.
#define FREEGLUT_STATIC
(the same goes for GLUT)
Here is a blog post that appens to talk about the same issue: http://mattfife.com/?p=226
Upvotes: 1