Using a dll library from one Visual Studio Express 2008 project in another

Coming from the Java world I would describe dlls as sort of jar files. A dll represents the component part of an application, that is: not the end-user part but rather the re-usable part of a Windows app. The so-called API of a dll is the .h file. That means the .h file contains all the methods, or functions that one can call on the dll.

To use the dll of Visual Studio (Express 2008) project A in project B we do what microsoft calls an implicit linking (http://msdn.microsoft.com/en-us/library/d14wsce5(VS.80).aspx). In more concrete terms here are the steps to follow:

1) Generate the dll of project A. When you do this, the linker (after-compiler thingy) creates both a dll and a lib file.
2) Copy the dll and the lib file to project B, namely to a place accessible by the compiler and the linker, a place that’s on the classpath to use the Java terminology.
3) Right-click on the project B in Visual Studio and select Configuration Properties -> Linker -> Input -> Additional Dependencies
4) There you can select the .lib counterpart of the dll (e.g. swill.lib in my case).

Add additional dependencies

Add additional dependencies

5) Add the header file (.h) of the dll to your project.

That’s it you should now be able to use the dll of A from project B, at least it worked fine for me.
Btw, being mainly a Java developer, I’m rather new to C++ so if that’s a silly way of doing it please do comment the post.

Comments (1)

DimitryApril 23rd, 2009 at 1:37 am

Thank you for clarifying that Application(client) has to be linked to .LIB file, and not .DLL!

Leave a comment

Your comment