GameNetworkingSockets icon indicating copy to clipboard operation
GameNetworkingSockets copied to clipboard

incorrectly detecting if bcrypt is available

Open malytomas opened this issue 2 years ago • 3 comments

In https://github.com/ValveSoftware/GameNetworkingSockets/blob/1e724c3248eefd0f49003ce2843140495e2cb475/CMakeLists.txt#L92 the test for bcrypt is incorrect.

Bcrypt functions are in bcrypt.h, not in windows.h. (the actual include in the code is correct, just the test in cmake is wrong.)

I got that response here: https://stackoverflow.com/questions/76620272/missing-bcrypt-in-github-actions-windows-2019/76624127#76624127

malytomas avatar Jul 05 '23 23:07 malytomas

LoL, for me it works as is, but when I change windows.h to bcrypt.h, it doesn't work.

I suspect it has something to do with the version of the compiler or Windows platform SDK. I've got this, what do you have?

INCLUDE=C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Tools\MSVC\14.29.30133\ATLMFC\include;
C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Tools\MSVC\14.29.30133\include;
C:\Program Files (x86)\Windows Kits\NETFXSDK\4.8\include\um;
C:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\ucrt;
C:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\shared;
C:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\um;
C:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\winrt;
C:\Program Files (x86)\Windows Kits\10\include\10.0.1;

zpostfacto avatar Jul 12 '23 00:07 zpostfacto

You are right - it does not help :( I have made some attempts and updated the question on stack overflow.

malytomas avatar Jul 12 '23 03:07 malytomas

this works for me on my developer machine, as well as on windows-2022 and windows-2019 github actions runners:

try_compile(bcryptAvailable "${CMAKE_CURRENT_BINARY_DIR}/tryCompile" SOURCES "${CMAKE_CURRENT_LIST_DIR}/tryCompileBcrypt.cpp" OUTPUT_VARIABLE bcryptMessages)
message(STATUS "bcryptAvailable: ${bcryptAvailable}")

tryCompileBcrypt.cpp:

#include <Windows.h>
#include <bcrypt.h>
#include <cstdio>
#pragma comment(lib, "bcrypt.lib")

int main(int, char **)
{
	printf("%p\n", &BCryptEncrypt);
}

please try this in your usecase (xbox?). ;)

malytomas avatar Jul 13 '23 16:07 malytomas