.obj, .lib and .dll?
-
Being a begginer, I have many problems... Consider this situation Suppose I am building a usefull library. One way is that I distribute it along with all the source and all the header files.... Right? Client programer will include the main header and will start using the functionality present in the library. Other scenario, what if I only give him the header files along with lib files? How I can do that? Means what compiler options I will have to set? (Assuming I am using VC.NET 2003) Lastly, I present here a realife example that somewhat confused me... Its the FreeType Library which is a true type rasterizer. http://www.freetype.org There are two distributions, one is the source of the library, and the other is library in usable form. I set my include paths as indicated by the documentation of FreeType. When I compile, I get "Uresovled symbols in function _tmain()". Ok, I figure out that either I have to provide the linker with the .lib file. Ok, I do so... All very well... Program complies and executes but terminates... It says "Cannot load library freetype6.dll". At the next step I find the .dll library and place it in the current directory of the program. Now I compile, and execute... all very well... Program is running... My question is that when I provided it with .lib file, FreeType library should be statically linked to my program why it requires the .dll to be accessible for the EXE? Please explain me what are .obj and .lib and .dll files are and what is there relation to each other and how they fit togather? Morevoer, if there is any article, book or tutorial on these issues, please let me know... If anything seems to you stupid, please dont mind as I am a begginer... Best regards, Mohsin Hijazee Polite Programmer
More Object Oriented then C#
-
Being a begginer, I have many problems... Consider this situation Suppose I am building a usefull library. One way is that I distribute it along with all the source and all the header files.... Right? Client programer will include the main header and will start using the functionality present in the library. Other scenario, what if I only give him the header files along with lib files? How I can do that? Means what compiler options I will have to set? (Assuming I am using VC.NET 2003) Lastly, I present here a realife example that somewhat confused me... Its the FreeType Library which is a true type rasterizer. http://www.freetype.org There are two distributions, one is the source of the library, and the other is library in usable form. I set my include paths as indicated by the documentation of FreeType. When I compile, I get "Uresovled symbols in function _tmain()". Ok, I figure out that either I have to provide the linker with the .lib file. Ok, I do so... All very well... Program complies and executes but terminates... It says "Cannot load library freetype6.dll". At the next step I find the .dll library and place it in the current directory of the program. Now I compile, and execute... all very well... Program is running... My question is that when I provided it with .lib file, FreeType library should be statically linked to my program why it requires the .dll to be accessible for the EXE? Please explain me what are .obj and .lib and .dll files are and what is there relation to each other and how they fit togather? Morevoer, if there is any article, book or tutorial on these issues, please let me know... If anything seems to you stupid, please dont mind as I am a begginer... Best regards, Mohsin Hijazee Polite Programmer
More Object Oriented then C#
Polite Programmer wrote:
My question is that when I provided it with .lib file, FreeType library should be statically linked to my program why it requires the .dll to be accessible for the EXE?
No, this is not entirely true. The lib files doesn't not contain the code of the library but rather the 'prototypes' of the functions from the dll. So, you need to link with it in order to know wich are the functions from your dll. Then, of course you need to have your dll in your working folder in order to load the functions at run-time. You don't need the lib file only if you load explicitely the functions from the dll (using LoadLibrary and GetProcAddress). Of course, you can also have lib files which contain code (so, that are not associated with a dll).
Cédric Moonen Software developer
Charting control -
Polite Programmer wrote:
My question is that when I provided it with .lib file, FreeType library should be statically linked to my program why it requires the .dll to be accessible for the EXE?
No, this is not entirely true. The lib files doesn't not contain the code of the library but rather the 'prototypes' of the functions from the dll. So, you need to link with it in order to know wich are the functions from your dll. Then, of course you need to have your dll in your working folder in order to load the functions at run-time. You don't need the lib file only if you load explicitely the functions from the dll (using LoadLibrary and GetProcAddress). Of course, you can also have lib files which contain code (so, that are not associated with a dll).
Cédric Moonen Software developer
Charting controlOne more major difference is .lib file comes into picture at Compile time. Where as .dll comes into picture at Run Time. Appu.. "If you judge people, you have no time to love them."
-
One more major difference is .lib file comes into picture at Compile time. Where as .dll comes into picture at Run Time. Appu.. "If you judge people, you have no time to love them."
It implies that if I create a DLL, I will get a .LIB file for free? Any details or any article addressing these issues please? Polite Programmer
More Object Oriented then C#