Adding my DLL into a Visual Studio project in C++

Reaper9806 picture Reaper9806 · Jul 23, 2015 · Viewed 38.6k times · Source

I am working on a project that involves making a dynamic link library, so I want to test it in a console app in Visual Studio.

The DLL is also made in Visual Studio, it doesn't have much, just a few functions in it. I'm not sure if I'm just supposed to include the librarys header in the include directories panel in Properties, or do something else

A lot of people say I'm supposed to add its corresponding .lib file in the Library or Reference directory, but I'm not sure that VS generates a .lib file alongside the DLL. I'm using VS 2015.

Answer

V-R picture V-R · Jul 23, 2015

I don't have VS in front of me this very moment, but these should be the general steps to set it up:

Properties->Linker->Input: your.lib
Properties->Linker->Additional Library Directories: ../your/bin
Properties->General->Compiler->Additional Include Directories: ../your/include

To build your app, the DLL's API headers must be in the include for the compile-time, it's LIB files in the bin for the link-time. Once you have your app EXE, all you need is the DLL to be in the same folder as your EXE when it executes.

You might also want to add the dll project and the app project into a common solution in VS and add (right click) Project Dependency from the app to the dll. This ensures correct order of building, assuming you are going to build the dll at all.