I am attempting to build a program in Visual Studio 2019 that is using the GLFW pre-compiled static library (if it matters, it is for Vulkan and not OpenGL). When I build in debug mode, it compiles just fine. When I compile in release mode, I get the following errors:
Error LNK2001 unresolved external symbol __security_check_cookie [myapp] [project_path]\glfw3.lib(win32_joystick.obj) 1
Error LNK2001 unresolved external symbol __security_check_cookie [myapp] [project_path]\glfw3.lib(wgl_context.obj) 1
Error LNK2001 unresolved external symbol __security_check_cookie [myapp] [project_path]\glfw3.lib(egl_context.obj) 1
Error LNK2001 unresolved external symbol __security_check_cookie [myapp] [project_path]\glfw3.lib(osmesa_context.obj) 1
Error LNK2001 unresolved external symbol __security_check_cookie [myapp] [project_path]\glfw3.lib(input.obj) 1
Error LNK2001 unresolved external symbol __security_check_cookie [myapp] [project_path]\glfw3.lib(win32_init.obj) 1
Error LNK2001 unresolved external symbol __security_check_cookie [myapp] [project_path]\glfw3.lib(win32_monitor.obj) 1
Error LNK2001 unresolved external symbol __security_check_cookie [myapp] [project_path]\glfw3.lib(context.obj) 1
and many more errors just like those relating to glfw.
I have already checked that:
a) both my debug and release configurations are configured exactly the same for linking to glfw.
b) the glfw3.lib file comes from the latest download of pre-compiled binaries in the lib-vc2019 folder.
c) They are the 64-bit binaries and both debug and release are building in 64-bit mode
Just for testing, I also tried the 32-bit binaries (obviously didn't work) and I also removed the library just to make sure both builds gave the same error message (they did)
The only glfw functions I use are
glfwInit()
glfwGetRequiredInstanceExtensions()
glfwCreateWindow()
glfwCreateWindowSurface()
glfwDestroyWindow()
glfwTerminate()
I'm guessing code is not the issue; but that it is caused by some compiler setting I don't know about that is different by default in the release configuration.
Based on Adrian's answer, I checked the other configurations in that category and found that the "Runtime Library" option under "C/C++ Code Generation" was the problem. In debug, it is set to "Multi-threaded Debug DLL (/MDd)" and in release it is set to "Multi-threaded DLL (/MD)". After changing it to the debug DLL, the release build compiles and runs without issue.
This seems like a glfw bug, but for what it is changing this setting works