c++windowsvisual-studioincludedetours

Visual Studio C++ "Function definition not found" on include


I downloaded the detours source code and compiled it with nmake. Now I want to include it in a C++ project so I added the include directory path to the include directories as well as the #include "detours.h" on top of the C++ source file. The previously unresolved detours.h is now fixed however I still get Function definition not found errors in the detours.h file itself:

This causes a few linker errors like the following:

Error   LNK2019 unresolved external symbol _DetourTransactionBegin@0 referenced in function "unsigned long __stdcall InitializeHooks(void *)" (?InitializeHooks@@YGKPAX@Z)

The detours folder looks like this:

I already cleaned the solution and rebuilt it but the errors persist. Is there anything else I need to do to make it work? How do I tell Visual Studio where to look up the function definitions since specifying the includes doesn't seem to be enough?


Solution

  • I forgot to pass the .lib files to the linker as well:

    Furthermore adding the libraries to the Library Directories path so the .lib files can be found at all.

    Now the linker errors are gone.