1

I'm trying to link my project (C++ console application) to an external static library (basically a .lib file and a .h header file), in Visual Studio 2015.

I've added the path of the folder which contains the .lib (a specific folder I've created, under the project's root folder, which contains the .lib file only), under the project properties, to

  1. "C/C++ - General - Additional Include Directories"
  2. "Linker - General - Additional Library Directories"

And I've also added the file name to "Linker - Input - Additional Dependencies". As a test, I've tried to specify the wrong file name - this caused an LNK1104 error (which doesn't occur when the correct name is specified).

For some reason, once I #include the library header (.h file) into my main.cpp file, a "system error" accures -

The program can't start because external_dll.dll is missing from your computer [..]

For some reason, the Linker looks for a .dll file, based on the name of the #included header - despite the fact that I've linked the project with the static library (.lib file).

This .dll file, of course, doesn't exist.

Am I missing something here?

golosovsky
  • 638
  • 1
  • 6
  • 19

2 Answers2

1

If folllowing is the case: -

"For some reason, the Linker looks for a .dll file, based on the name of the #included header - despite the fact that I've linked the project with the static library (.lib file)."

then there should be some way of disabling this feature, I mean in project setting of VS2015, one should be able to make linker to stop looking for dll file corresponding dll #include header file.

Also there is exclude field as well, if you couldn't do the above, you may try excluding the dll file which you are coming across and then take it from there.

MGpro
  • 33
  • 4
0

Your application just cannot find the DLL file. The simplest solution is to put that DLL into the folder with your exe file.

Dmitry T.
  • 673
  • 7
  • 7
  • Obviously, the static library just statically links your application with some DLL in your case. http://stackoverflow.com/questions/424032/how-to-link-a-dll-statically – Dmitry T. Dec 06 '16 at 10:37
  • 1
    @golosovsky - Are you _absolutely certain_ there isn't supposed to be a DLL? **Many** DLL-based libraries come with a .h (for compile-time), a .lib (for link-time) and a .dll (for run-time). In these cases, the H and LIB are often a simple wrapper that loads the DLL and does any necessary get proc address stuff, as well as handling any ABI issues - but the DLL is still required at run-time. – Allison Lock Dec 06 '16 at 10:40