Reputation: 10476
At past I have used dll made by other developers in my application. Now, my wish is to learn about making dll files. So, I started developing dll file in visual studio 2008 as c++ project.
After following a tutorial, I successfully created the dll project. And, when I created another c++ console application to test the aforementioned dll I experienced that I needed to include the lib file and a header file of the previous dll project. I guess including self made header depends on how i implement my project.But, what about including the lib file in the client application ?
Isn't that an additional dependency ? If my question is not clear then I am going to explain it briefly again: I have created a dll file as VS2008 c++ project. When I try to access the dll from another c++ project , I needed to include the lib file of the previous project. So, I wish to know how could I avoid including anything or any dependency and still use the dll in my client application...
If my words make no sense, then sorry... I am newbie in dll related stuff...
Upvotes: 0
Views: 331
Reputation: 6130
The LIB file is an import library which contains code for loading the DLL at runtime; Visual studio creates it for your convenience so that you don't need to write a bunch of boilerplate import code in your client application.
Lib files are statically linked, so there is no additional dependency as far as your client application is concerned.
Upvotes: 1
Reputation: 12445
You have two problems (suppose that your library is LibA and the other library is LibB):
Headers dependency: LibA headers files seem to have #include directives to read header files of LibB. In this case, when you load your LIbA into another project, these #include cannot be resolved without including LibB headers path. To avoid this, you must create LibA in a way that LibB headers appear only in .cpp files and not in .h files. One option is to use "Forward Declaration" for this (check on internet and you'll learn a lot, it's useless to repeat here the basics).
Library dependency: if your .dll is dependent by another .dll, you cannot do anything but use both libraries, because simply LibA doesn't work without LibB. One solution is to have LibB as static library, and then statically link it in LibA, so it's include in LibA.dll and you need only this (you need always both of them, but LibB binaries is now inside LibA file).
Upvotes: 0