在调试配置中编译工作正常,但发布会给出链接错误



我在Visual Studio 2017中使用GLFW(glfw3.lib,而不是glfw3dll.lib(和GLAD (glad.c(。在调试配置中编译工作正常,而发布版本会引发奇怪的链接器错误。这些是"未解析的外部符号":

1>glad.obj : error LNK2001: unresolved external symbol __security_check_cookie
1>glad.obj : error LNK2001: unresolved external symbol __imp_realloc
1>glad.obj : error LNK2001: unresolved external symbol __imp_strncmp
1>glad.obj : error LNK2001: unresolved external symbol __imp_free
1>glad.obj : error LNK2001: unresolved external symbol strstr
1>glad.obj : error LNK2001: unresolved external symbol __imp___stdio_common_vsscanf
1>glad.obj : error LNK2001: unresolved external symbol __imp_malloc
1>Game.obj : error LNK2001: unresolved external symbol __CxxFrameHandler3
1>Game.obj : error LNK2001: unresolved external symbol glfwSwapBuffers
1>Game.obj : error LNK2001: unresolved external symbol __imp_exit
1>Game.obj : error LNK2001: unresolved external symbol glfwGetKey
1>Game.obj : error LNK2001: unresolved external symbol "void * __cdecl operator new(unsigned __int64)" (??2@YAPEAX_K@Z)
1>Game.obj : error LNK2001: unresolved external symbol glfwTerminate
1>Game.obj : error LNK2001: unresolved external symbol glfwPollEvents
1>Game.obj : error LNK2001: unresolved external symbol glfwInit
1>Game.obj : error LNK2001: unresolved external symbol glfwSetWindowShouldClose
1>Game.obj : error LNK2001: unresolved external symbol glfwCreateWindow
1>Game.obj : error LNK2001: unresolved external symbol "void __cdecl operator delete(void *,unsigned __int64)" (??3@YAXPEAX_K@Z)
1>Game.obj : error LNK2001: unresolved external symbol glfwWindowHint
1>Game.obj : error LNK2001: unresolved external symbol glfwMakeContextCurrent
1>Game.obj : error LNK2001: unresolved external symbol glfwSetWindowTitle
1>Game.obj : error LNK2001: unresolved external symbol glfwGetProcAddress
1>Game.obj : error LNK2001: unresolved external symbol __std_terminate
1>Game.obj : error LNK2001: unresolved external symbol glfwWindowShouldClose
1>Game.obj : error LNK2001: unresolved external symbol __imp__invalid_parameter_noinfo_noreturn
1>Game.obj : error LNK2001: unresolved external symbol __imp_getenv
1>LINK : error LNK2001: unresolved external symbol mainCRTStartup
1>C:UsersUserDocumentsVisual Studio SolutionsOrder of the StoneOrder of the Stonex64ReleaseOrder of the Stone.exe : fatal error LNK1120: 27 unresolved externals
运行时库选项是"多线程 DLL">

("多线程调试 DLL"用于调试(。我正在使用预编译的Windows GLFW二进制文件。Windows SDK是Windows 10 SDK。

任何帮助,不胜感激。

>编辑我已经检查了包含目录以进行发布,结果发现它是针对错误的架构(32 位而不是 64 位(。但现在它给出了另一个未解析的外部列表:

1>glfw3.lib(monitor.c.obj) : error LNK2001: unresolved external symbol __security_check_cookie
1>glfw3.lib(wgl_context.c.obj) : error LNK2001: unresolved external symbol __security_check_cookie
1>glfw3.lib(egl_context.c.obj) : error LNK2001: unresolved external symbol __security_check_cookie
1>glfw3.lib(win32_window.c.obj) : error LNK2001: unresolved external symbol __security_check_cookie
1>glfw3.lib(win32_joystick.c.obj) : error LNK2001: unresolved external symbol __security_check_cookie
1>glfw3.lib(win32_init.c.obj) : error LNK2001: unresolved external symbol __security_check_cookie
1>glfw3.lib(win32_monitor.c.obj) : error LNK2001: unresolved external symbol __security_check_cookie
1>glad.obj : error LNK2001: unresolved external symbol __security_check_cookie
1>glfw3.lib(context.c.obj) : error LNK2001: unresolved external symbol __security_check_cookie
1>glfw3.lib(init.c.obj) : error LNK2001: unresolved external symbol __security_check_cookie
1>glfw3.lib(window.c.obj) : error LNK2001: unresolved external symbol __security_check_cookie
1>glad.obj : error LNK2001: unresolved external symbol __imp_realloc
1>glfw3.lib(win32_monitor.c.obj) : error LNK2001: unresolved external symbol __imp_realloc
1>glad.obj : error LNK2001: unresolved external symbol __imp_strncmp
1>glfw3.lib(context.c.obj) : error LNK2001: unresolved external symbol __imp_strncmp
1>glfw3.lib(egl_context.c.obj) : error LNK2001: unresolved external symbol __imp_strncmp
1>glfw3.lib(vulkan.c.obj) : error LNK2001: unresolved external symbol __imp_free
1>glfw3.lib(wgl_context.c.obj) : error LNK2001: unresolved external symbol __imp_free
1>glfw3.lib(egl_context.c.obj) : error LNK2001: unresolved external symbol __imp_free
1>glfw3.lib(win32_joystick.c.obj) : error LNK2001: unresolved external symbol __imp_free
1>glfw3.lib(win32_init.c.obj) : error LNK2001: unresolved external symbol __imp_free
1>glfw3.lib(win32_monitor.c.obj) : error LNK2001: unresolved external symbol __imp_free
1>glfw3.lib(monitor.c.obj) : error LNK2001: unresolved external symbol __imp_free
1>glad.obj : error LNK2001: unresolved external symbol __imp_free
1>glfw3.lib(input.c.obj) : error LNK2001: unresolved external symbol __imp_free
1>glfw3.lib(window.c.obj) : error LNK2001: unresolved external symbol __imp_free
1>glfw3.lib(win32_window.c.obj) : error LNK2001: unresolved external symbol __imp_free
1>glad.obj : error LNK2001: unresolved external symbol strstr
1>glad.obj : error LNK2001: unresolved external symbol __imp___stdio_common_vsscanf
1>glfw3.lib(context.c.obj) : error LNK2001: unresolved external symbol __imp___stdio_common_vsscanf
1>glad.obj : error LNK2001: unresolved external symbol __imp_malloc
1>Game.obj : error LNK2001: unresolved external symbol __CxxFrameHandler3
1>Game.obj : error LNK2001: unresolved external symbol __imp_exit
1>Game.obj : error LNK2001: unresolved external symbol "void * __cdecl operator new(unsigned __int64)" (??2@YAPEAX_K@Z)
1>Game.obj : error LNK2001: unresolved external symbol "void __cdecl operator delete(void *,unsigned __int64)" (??3@YAXPEAX_K@Z)
1>Game.obj : error LNK2001: unresolved external symbol __std_terminate
1>Game.obj : error LNK2001: unresolved external symbol __imp__invalid_parameter_noinfo_noreturn
1>Game.obj : error LNK2001: unresolved external symbol __imp_getenv
1>LINK : error LNK2001: unresolved external symbol mainCRTStartup
1>glfw3.lib(context.c.obj) : error LNK2001: unresolved external symbol __imp_strstr
1>glfw3.lib(win32_joystick.c.obj) : error LNK2001: unresolved external symbol __imp_strstr
1>glfw3.lib(wgl_context.c.obj) : error LNK2001: unresolved external symbol __GSHandlerCheck
1>glfw3.lib(egl_context.c.obj) : error LNK2001: unresolved external symbol __GSHandlerCheck
1>glfw3.lib(win32_joystick.c.obj) : error LNK2001: unresolved external symbol __GSHandlerCheck
1>glfw3.lib(win32_init.c.obj) : error LNK2001: unresolved external symbol __GSHandlerCheck
1>glfw3.lib(win32_monitor.c.obj) : error LNK2001: unresolved external symbol __GSHandlerCheck
1>glfw3.lib(monitor.c.obj) : error LNK2001: unresolved external symbol __GSHandlerCheck
1>glfw3.lib(context.c.obj) : error LNK2001: unresolved external symbol __GSHandlerCheck
1>glfw3.lib(init.c.obj) : error LNK2001: unresolved external symbol __GSHandlerCheck
1>glfw3.lib(window.c.obj) : error LNK2001: unresolved external symbol __GSHandlerCheck
1>glfw3.lib(win32_window.c.obj) : error LNK2001: unresolved external symbol __GSHandlerCheck
1>glfw3.lib(wgl_context.c.obj) : error LNK2001: unresolved external symbol __security_cookie
1>glfw3.lib(egl_context.c.obj) : error LNK2001: unresolved external symbol __security_cookie
1>glfw3.lib(win32_joystick.c.obj) : error LNK2001: unresolved external symbol __security_cookie
1>glfw3.lib(win32_init.c.obj) : error LNK2001: unresolved external symbol __security_cookie
1>glfw3.lib(win32_monitor.c.obj) : error LNK2001: unresolved external symbol __security_cookie
1>glfw3.lib(monitor.c.obj) : error LNK2001: unresolved external symbol __security_cookie
1>glfw3.lib(context.c.obj) : error LNK2001: unresolved external symbol __security_cookie
1>glfw3.lib(init.c.obj) : error LNK2001: unresolved external symbol __security_cookie
1>glfw3.lib(window.c.obj) : error LNK2001: unresolved external symbol __security_cookie
1>glfw3.lib(win32_window.c.obj) : error LNK2001: unresolved external symbol __security_cookie
1>glfw3.lib(wgl_context.c.obj) : error LNK2001: unresolved external symbol __imp_calloc
1>glfw3.lib(egl_context.c.obj) : error LNK2001: unresolved external symbol __imp_calloc
1>glfw3.lib(win32_init.c.obj) : error LNK2001: unresolved external symbol __imp_calloc
1>glfw3.lib(win32_monitor.c.obj) : error LNK2001: unresolved external symbol __imp_calloc
1>glfw3.lib(monitor.c.obj) : error LNK2001: unresolved external symbol __imp_calloc
1>glfw3.lib(vulkan.c.obj) : error LNK2001: unresolved external symbol __imp_calloc
1>glfw3.lib(input.c.obj) : error LNK2001: unresolved external symbol __imp_calloc
1>glfw3.lib(window.c.obj) : error LNK2001: unresolved external symbol __imp_calloc
1>glfw3.lib(win32_window.c.obj) : error LNK2001: unresolved external symbol __imp_calloc
1>glfw3.lib(win32_joystick.c.obj) : error LNK2001: unresolved external symbol __imp_calloc
1>glfw3.lib(monitor.c.obj) : error LNK2001: unresolved external symbol _fltused
1>glfw3.lib(input.c.obj) : error LNK2001: unresolved external symbol _fltused
1>glfw3.lib(window.c.obj) : error LNK2001: unresolved external symbol _fltused
1>glfw3.lib(win32_window.c.obj) : error LNK2001: unresolved external symbol _fltused
1>glfw3.lib(win32_joystick.c.obj) : error LNK2001: unresolved external symbol _fltused
1>glfw3.lib(init.c.obj) : error LNK2001: unresolved external symbol __imp___stdio_common_vsprintf
1>glfw3.lib(init.c.obj) : error LNK2001: unresolved external symbol __chkstk
1>glfw3.lib(win32_init.c.obj) : error LNK2001: unresolved external symbol memset
1>glfw3.lib(win32_monitor.c.obj) : error LNK2001: unresolved external symbol memset
1>glfw3.lib(init.c.obj) : error LNK2001: unresolved external symbol memset
1>glfw3.lib(window.c.obj) : error LNK2001: unresolved external symbol memset
1>glfw3.lib(win32_window.c.obj) : error LNK2001: unresolved external symbol memset
1>glfw3.lib(win32_joystick.c.obj) : error LNK2001: unresolved external symbol memset
1>glfw3.lib(win32_window.c.obj) : error LNK2001: unresolved external symbol __imp__strdup
1>glfw3.lib(win32_joystick.c.obj) : error LNK2001: unresolved external symbol __imp__strdup
1>glfw3.lib(monitor.c.obj) : error LNK2001: unresolved external symbol __imp__strdup
1>glfw3.lib(win32_joystick.c.obj) : error LNK2001: unresolved external symbol __imp_qsort
1>glfw3.lib(monitor.c.obj) : error LNK2001: unresolved external symbol __imp_qsort
1>glfw3.lib(win32_joystick.c.obj) : error LNK2001: unresolved external symbol sqrt
1>glfw3.lib(monitor.c.obj) : error LNK2001: unresolved external symbol pow
1>glfw3.lib(vulkan.c.obj) : error LNK2001: unresolved external symbol strcmp
1>C:UsersUserDocumentsVisual Studio SolutionsOrder of the StoneOrder of the Stonex64ReleaseOrder of the Stone.exe : fatal error LNK1120: 28 unresolved externals

请注意,32 位发布工作正常,它是 64 位发布版本存在这些奇怪的链接器错误。

由于某种原因Debug64 位 GLFW 预构建的 Windows 二进制文件,因此无法链接,因为我的应用程序处于Release中,没有提供必要的调试定义。解决方案要么在发布配置中自己从源代码编译 GLFW,要么根本不使用 64 位 GLFW(奇怪的是 32 位二进制Release,因为我能够在x86/Release中构建我的应用程序(。但是,我无法实际证明这一点,因为我不再使用 GLFW,因为它不适合我的需求。

最新更新