【发布时间】:2018-08-13 12:13:02
【问题描述】:
我在 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:\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。
感谢任何帮助。
编辑
我检查了包含目录的发布,结果发现它是错误的架构(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 位 Release 可以正常工作,但 64 位 Release 版本会出现这些奇怪的链接器错误。
【问题讨论】:
-
您是否真的将 .libs 添加到发布模式的配置中?您可以为每个配置设置选项,所以我怀疑您这样做是为了调试,而不是为了发布。
-
@Zinki Additional Include Directories 是正确的,我检查了两次。要包含的实际库在包含在所有配置中的标头 (
#pragma comment(lib, "glfw3.lib")) 中指定。 -
@HansPassant 我编辑了问题,提供了更多细节
-
看起来像是链接到发布应用程序的 glfw3.lib bing 的调试版本
-
@AlanBirtles 所以我应该在发布配置中从源代码重建 GLFW,然后将其链接到我的应用程序?
标签: c++ visual-c++ glfw