我正在尝试使用OpenGL。但是,每次我使用Visual Studio并按本地Windows调试器时,都会出现上述错误(链接:致命错误LNK1104:无法打开文件'glfw3.lib')。
我的文件结构是这个
DOCUMENTS
- Visual Studio 2019
- Projects
- OpenGlProject
- sln and everything else (including glfw3.dll, and glew32.dll)
- External Libs
- GLFW
- include
- glfw3.h
- lib-vc2019
- glfw3.lib
- GLEW
- include
- GL
- all glew.h files
- lib
- Release
- Win32
-glew32.lib
我将.h文件包括在其中
$(SolutionDir)/../../../ExternalLibs/GLEW/include
$(SolutionDir)/../../../ExternalLibs/GLFW/include
lib文件包含在
中$(SolutionDir)/../../../ExternalLibs GLFW/lib-vc2019
$(SolutionDir)/../../../ExternalLibs/GLEW/lib/Release/Win32
链接器输入文件如下所示
opengl32.lib
glew32.lib
glfw3.lib
我以为我做对了所有事情,那又是什么问题呢?我到处都看了,没有有用的东西出现。感谢您的提前帮助,欢呼!
超级用户链接:https://superuser.com/questions/1483664/link-fatal-error-lnk1104-cannot-open-file-glfw3-lib
更新:我更新了Windows SDK,但仍然再次遇到相同的错误,因此我尝试将目录更改为准确的位置(C:\ something \ blah blah),并且出现了所有这些错误:
1>main.cpp
1>LINK : warning LNK4098: defaultlib 'MSVCRT' conflicts with use of other libs; use /NODEFAULTLIB:library
1>LINK : warning LNK4286: symbol '_free' defined in 'libucrtd.lib(free.obj)' is imported by 'glfw3.lib(win32_joystick.obj)'
1>LINK : warning LNK4286: symbol '_free' defined in 'libucrtd.lib(free.obj)' is imported by 'glfw3.lib(wgl_context.obj)'
1>LINK : warning LNK4286: symbol '_free' defined in 'libucrtd.lib(free.obj)' is imported by 'glfw3.lib(egl_context.obj)'
1>LINK : warning LNK4286: symbol '_free' defined in 'libucrtd.lib(free.obj)' is imported by 'glfw3.lib(osmesa_context.obj)'
1>LINK : warning LNK4286: symbol '_free' defined in 'libucrtd.lib(free.obj)' is imported by 'glfw3.lib(win32_monitor.obj)'
1>LINK : warning LNK4286: symbol '_free' defined in 'libucrtd.lib(free.obj)' is imported by 'glfw3.lib(monitor.obj)'
1>LINK : warning LNK4286: symbol '_free' defined in 'libucrtd.lib(free.obj)' is imported by 'glfw3.lib(vulkan.obj)'
1>LINK : warning LNK4286: symbol '_free' defined in 'libucrtd.lib(free.obj)' is imported by 'glfw3.lib(win32_window.obj)'
1>LINK : warning LNK4217: symbol '_free' defined in 'libucrtd.lib(free.obj)' is imported by 'glfw3.lib(init.obj)' in function '_terminate'
1>LINK : warning LNK4286: symbol '_free' defined in 'libucrtd.lib(free.obj)' is imported by 'glfw3.lib(window.obj)'
1>LINK : warning LNK4286: symbol '_free' defined in 'libucrtd.lib(free.obj)' is imported by 'glfw3.lib(input.obj)'
1>LINK : warning LNK4286: symbol '_free' defined in 'libucrtd.lib(free.obj)' is imported by 'glfw3.lib(win32_init.obj)'
1>LINK : warning LNK4217: symbol '___stdio_common_vsprintf' defined in 'libucrtd.lib(output.obj)' is imported by 'glfw3.lib(init.obj)' in function '__glfwInputError'
1>LINK : warning LNK4286: symbol '___stdio_common_vsprintf' defined in 'libucrtd.lib(output.obj)' is imported by 'glfw3.lib(win32_joystick.obj)'
1>LINK : warning LNK4217: symbol '_strncmp' defined in 'libucrtd.lib(strncmp.obj)' is imported by 'glfw3.lib(context.obj)' in function '__glfwRefreshContextAttribs'
1>LINK : warning LNK4286: symbol '_strncmp' defined in 'libucrtd.lib(strncmp.obj)' is imported by 'glfw3.lib(input.obj)'
1>LINK : warning LNK4217: symbol '_strncmp' defined in 'libucrtd.lib(strncmp.obj)' is imported by 'glfw3.lib(egl_context.obj)' in function '__glfwCreateContextEGL'
1>LINK : warning LNK4217: symbol '_strtoul' defined in 'libucrtd.lib(strtox.obj)' is imported by 'glfw3.lib(input.obj)' in function '_parseMapping'
1>LINK : warning LNK4217: symbol '_qsort' defined in 'libucrtd.lib(qsort.obj)' is imported by 'glfw3.lib(monitor.obj)' in function '_refreshVideoModes'
1>LINK : warning LNK4217: symbol '_qsort' defined in 'libucrtd.lib(qsort.obj)' is imported by 'glfw3.lib(win32_joystick.obj)' in function '_deviceCallback@8'
1>glfw3.lib(win32_joystick.obj) : error LNK2001: unresolved external symbol __imp__calloc
1>glfw3.lib(wgl_context.obj) : error LNK2001: unresolved external symbol __imp__calloc
1>glfw3.lib(egl_context.obj) : error LNK2001: unresolved external symbol __imp__calloc
1>glfw3.lib(osmesa_context.obj) : error LNK2001: unresolved external symbol __imp__calloc
1>glfw3.lib(win32_monitor.obj) : error LNK2001: unresolved external symbol __imp__calloc
1>glfw3.lib(monitor.obj) : error LNK2001: unresolved external symbol __imp__calloc
1>glfw3.lib(vulkan.obj) : error LNK2001: unresolved external symbol __imp__calloc
1>glfw3.lib(win32_window.obj) : error LNK2001: unresolved external symbol __imp__calloc
1>glfw3.lib(init.obj) : error LNK2001: unresolved external symbol __imp__calloc
1>glfw3.lib(window.obj) : error LNK2001: unresolved external symbol __imp__calloc
1>glfw3.lib(input.obj) : error LNK2001: unresolved external symbol __imp__calloc
1>glfw3.lib(win32_init.obj) : error LNK2001: unresolved external symbol __imp__calloc
1>glfw3.lib(window.obj) : error LNK2019: unresolved external symbol __imp__strncpy referenced in function _glfwWindowHintString
1>glfw3.lib(input.obj) : error LNK2001: unresolved external symbol __imp__strncpy
1>glfw3.lib(win32_joystick.obj) : error LNK2001: unresolved external symbol __imp__strncpy
1>glfw3.lib(context.obj) : error LNK2019: unresolved external symbol __imp____stdio_common_vsscanf referenced in function _sscanf
1>glfw3.lib(input.obj) : error LNK2019: unresolved external symbol __imp__strcspn referenced in function _glfwUpdateGamepadMappings
1>glfw3.lib(input.obj) : error LNK2019: unresolved external symbol __imp__strspn referenced in function _glfwUpdateGamepadMappings
1>glfw3.lib(input.obj) : error LNK2019: unresolved external symbol __imp__realloc referenced in function _glfwUpdateGamepadMappings
1>glfw3.lib(win32_monitor.obj) : error LNK2001: unresolved external symbol __imp__realloc
1>glfw3.lib(monitor.obj) : error LNK2001: unresolved external symbol __imp__realloc
1>MSVCRT.lib(chandler4gs.obj) : error LNK2019: unresolved external symbol __except_handler4_common referenced in function __except_handler4
1>C:\Users\user\Documents\Visual Studio 2019\Projects\OpenGLCourseApp\Debug\OpenGLCourseApp.exe : fatal error LNK1120: 7 unresolved externals
所以我将其改回了$(SolutionDir),因为每个人的计算机都不同,并且用户名也不会相同,但是SolutionDir是相对的,因此它可以正常工作。所以现在我得到了原始错误。