0

I'm trying to do my first step with CNG (Cryptography Next Generation) in VC++ 2015 (Windows 10 x64). Here's the code:

#include "stdafx.h"
#include <windows.h>

int main()
{
    NTSTATUS status;
    ULONG cbBufSize = 0;
    PCRYPT_PROVIDERS pBuf = NULL;
    status = BCryptEnumRegisteredProviders(&cbBufSize, &pBuf);
    return 0;
}

Building the project (for x86), I got an error message:

Error LNK2019 unresolved external symbol _BCryptEnumRegisteredProviders@8 referenced in function _main

I then tried to install "CNG Software Development Kit" and configured the project following this instruction: http://www.codeproject.com/Articles/18713/Simple-way-to-crypt-a-file-with-CNG but project building gave the same error message.

Please help!

PS: I did the same thing in (Win7 x86, VS 2008) and it worked without any error.

jww
  • 97,681
  • 90
  • 411
  • 885
Vova
  • 53
  • 7
  • 2
    Did you indeed add `bcrypt.lib` to the linker's Additional dependencies, and does this file exist? – GSerg Apr 04 '16 at 01:05
  • @GSerg: Well, I forgot about the library file. I now added the file and the project was built without any error. Thank you! – Vova Apr 04 '16 at 07:36
  • But when I switched building mode from **Debug** to **Release**, the error appeared again. And when I copied the EXE-file (the result of building in **Debug** mode) to a Windows 7 x86 machine and tried to run it, I got error message "The program can't start because VCRUNTIME140D.dll is missing from your computer. Try reinstalling the program to fix the problem". Please help again, especially @GSerg. – Vova Apr 04 '16 at 08:08
  • Did you add `bcrypt.lib` for all build configurations, or just for Debug? – GSerg Apr 04 '16 at 09:33
  • Oh my god!!!!! How silly I am! Yes, I added the 'bcrypt.lib' just for **Debug** build configuration. The problem is now resolved! Thanks again, @GSerg! – Vova Apr 04 '16 at 10:12
  • Possible duplicate of [What is an undefined reference/unresolved external symbol error and how do I fix it?](http://stackoverflow.com/questions/12573816/what-is-an-undefined-reference-unresolved-external-symbol-error-and-how-do-i-fix) – Ken White May 02 '16 at 00:47

0 Answers0