How do I link a DLL to my project? error LNK2019: unresolved external symbol How do I link a DLL to my project? error LNK2019: unresolved external symbol windows windows

How do I link a DLL to my project? error LNK2019: unresolved external symbol


You should have received at least three files from the DLL owner. The DLL which you'll need at runtime, the .h file with the declarations of the exported functions, you already have that. And a .lib file, the import library for the DLL. Which the linker requires so it knows how to add the functions to the program's import table.

You are missing the step where you told the linker that it needs to link the .lib file. It needs to be added to the linker's Input + Additional Dependencies setting of your project. Or most easily done by writing the linker instruction in your source code:

#include "foo.h"#pragma comment(lib, "foo.lib")

Which works for MSVC, not otherwise portable but linking never is. Copy the .lib file to your project directory or specify the full path.


I just had a similar problem. The solution turned out to be that the DLL was 64 bit, and the simple app using it was 32. I had forgotten to change it to x64 in the Configuration Manager.


  1. You need to specify in front of function definitions __declspec(dllexport) keyword at the time of building the dll
  2. You need to import or load the .dll file into process memory.
  3. You need to acquire the address of function you want to use from that dll.

Some useful links to get started:: MSDN Documentation, SO, Random