我在Visual Studio 2017中使用GLFW(glfw3.lib
,而不是glfw3dll.lib
)和GLAD(glad.c
)。在Debug配置中编译可以很好地工作,而Release版本会抛出奇怪的链接器错误。这些是“无法解析的外部符号”:
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:\Users\User\Documents\Visual Studio Solutions\Order of the Stone\Order of the Stone\x64\Release\Order of the Stone.exe : fatal error LNK1120: 27 unresolved externals
运行时库选项为“多线程DLL”(用于调试的“多线程调试DLL”)。我正在使用预编译的Windows GLFW二进制文件。 Windows SDK是Windows 10 SDK。
感谢您的帮助。
我检查了include目录以进行发布,结果证明它使用的是错误的体系结构(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:\Users\User\Documents\Visual Studio Solutions\Order of the Stone\Order of the Stone\x64\Release\Order of the Stone.exe : fatal error LNK1120: 28 unresolved externals
请注意,32位版本的发行版工作正常,它是64位版本的发行版,具有这些奇怪的链接器错误。
答案 0 :(得分:0)
由于某种原因,由于64位GLFW预制Windows二进制文件是Debug
,因此它无法链接,因为我的应用程序位于Release
中,因此未提供必要的调试定义。解决方案是自己在Release配置中从源代码自己编译GLFW,或者根本不使用64位GLFW(奇怪的是,32位二进制文件是Release
,因为我可以在{{ 1}})。但是,我无法实际证明这一点,因为我不再使用GLFW,因为它不适合我的需求。