DLL Unresolved Character Errors

For the background, I came across this by porting the middle version of Linux code (compiling to giant .so) to x64 windows (compiling into .dll). I had problems with the linker.

As a minimal test file, if I create a Visual Studio project only from the following file:

#include <Windows.h> #include <Dbghelp.h> void do_stuff(char const * s) { char buffer[4096]; long int len = UnDecorateSymbolName( s, buffer, sizeof(buffer), UNDNAME_COMPLETE); } 

And I set the project type in the DLL and built it, I get the error message "LNK2001: unresolved external symbol __imp_UnDecorateSymbolName". That is, the file compiles correctly, but does not communicate with the dll.

I think the purpose of my dll is to link to dbghelp.dll, especially since (at least on my system) there is no such file as dbghelp.lib. So why is he trying to resolve this symbol now, and not when my DLL is loading into the application? And why can't he see this function anyway?

To be clear, I confirmed that I am creating an x64 DLL, and dbghelp.dll in C: \ Windows \ System32 - x64.

+6
source share
1 answer

Linking to shared libraries, Windows-talk DLLs require the following:

  • Compilation header file: Dbghelp.h .
  • Import library at link time: Dbghelp.lib .
  • Runtime DLL: Dbghelp.dll .

You obviously have 1 and 3 and not enough 2. The Windows SDK that comes with Visual Studio includes an import library. But you need to add it as an additional dependency in the project linker settings.

Like this:

enter image description here

+11
source

Source: https://habr.com/ru/post/909773/


All Articles