LNK2019 problem

c++, visual-c++

Solution

The MSDN page about LNK2019 already gives plenty of examples why this error occurs. In order to trace down what exactly is going on, I recommend doing this:

- Run `undname` on the symbol which the linker complains about to demangle the name (see Viewing Decorated Names for an example how to run `undname`).

- Run `dumpbin /EXPORTS` (or use the graphical Dependency Walker) to get a list of all symbols exported by DLL1.

So now you have the demangled name of the symbol which the linker tries to find, and you have the list of symbols which are exported by DLL1. And the linker tells you that it cannot find the requested symbol in the list. Here are two ideas about what's going on:

- You see that DLL1 has the demangled symbol in its export list, but not exactly the mangled name which the linker complains about. This can happen when the function you export is almost the same which the linker expects. It might be that you have a 'const' missing somewhere, or the calling convention is different.

- You see that DLL1 doesn't export any symbol which looks like what the linker expects. This suggests that some `__declspec(dllexport)` is missing in the declarations of DLL1.

Problem

I have a LNK2019 problem when trying to use some DLL in my project. Details: - I have a DLL project called dll1; that compiled just fine (using `__declspec(dllexport)`) in order to export the class inside dll1 (for dll2 usage). - I have another DLL project dll2 that uses dll1's functionality. I specified the *.dll1.lib file path inside the linker input in the project's properties and gave reference to dll1 *.h files. At this point everything needs to work fine. (I think..) - When compiling dll2, I get a LNK2019 error that tells me can't find some method referenced in dll1. (This method in dll1 is a static method.) Why do I get this error?

Original source

Related problems