我在链接 GLFW 时遇到了一个大问题。我在该站点和其他站点上看到过多个帖子,其中已经查看了此类错误消息,但是当我尝试修复时,错误仍然相同。特别是错误是:
Error 1 error LNK2019: unresolved external symbol __imp_SystemParametersInfoA referenced in function _glfwPlatformInit C:\Users\Asher\documents\visual studio 2012\Projects\Procedural Terrain\Procedural Terrain\GLFW.lib(win32_init.obj) Procedural Terrain
Error 2 error LNK2001: unresolved external symbol __imp_SystemParametersInfoA C:\Users\Asher\documents\visual studio 2012\Projects\Procedural Terrain\Procedural Terrain\GLFW.lib(win32_window.obj) Procedural Terrain
Error 3 error LNK2001: unresolved external symbol __imp_SystemParametersInfoA C:\Users\Asher\documents\visual studio 2012\Projects\Procedural Terrain\Procedural Terrain\GLFW.lib(win32_enable.obj) Procedural Terrain
Error 4 error LNK2019: unresolved external symbol __imp_DispatchMessageA referenced in function _glfwPlatformPollEvents C:\Users\Asher\documents\visual studio 2012\Projects\Procedural Terrain\Procedural Terrain\GLFW.lib(win32_window.obj) Procedural Terrain
Error 5 error LNK2019: unresolved external symbol __imp_PeekMessageA referenced in function _glfwPlatformPollEvents C:\Users\Asher\documents\visual studio 2012\Projects\Procedural Terrain\Procedural Terrain\GLFW.lib(win32_window.obj) Procedural Terrain
Error 6 error LNK2019: unresolved external symbol __imp_GetMessageTime referenced in function translateKey C:\Users\Asher\documents\visual studio 2012\Projects\Procedural Terrain\Procedural Terrain\GLFW.lib(win32_window.obj) Procedural Terrain
Error 7 error LNK2019: unresolved external symbol __imp_WaitMessage referenced in function _glfwPlatformWaitEvents C:\Users\Asher\documents\visual studio 2012\Projects\Procedural Terrain\Procedural Terrain\GLFW.lib(win32_window.obj) Procedural Terrain
Error 8 error LNK2019: unresolved external symbol __imp_DefWindowProcA referenced in function windowProc C:\Users\Asher\documents\visual studio 2012\Projects\Procedural Terrain\Procedural Terrain\GLFW.lib(win32_window.obj) Procedural Terrain
Error 9 error LNK2019: unresolved external symbol __imp_PostQuitMessage referenced in function windowProc C:\Users\Asher\documents\visual studio 2012\Projects\Procedural Terrain\Procedural Terrain\GLFW.lib(win32_window.obj) Procedural Terrain
Error 10 error LNK2019: unresolved external symbol __imp_RegisterClassA referenced in function registerWindowClass C:\Users\Asher\documents\visual studio 2012\Projects\Procedural Terrain\Procedural Terrain\GLFW.lib(win32_window.obj) Procedural Terrain
Error 11 error LNK2019: unresolved external symbol __imp_UnregisterClassA referenced in function _glfwPlatformCloseWindow C:\Users\Asher\documents\visual studio 2012\Projects\Procedural Terrain\Procedural Terrain\GLFW.lib(win32_window.obj) Procedural Terrain
Error 12 error LNK2019: unresolved external symbol __imp_CreateWindowExA referenced in function createWindow C:\Users\Asher\documents\visual studio 2012\Projects\Procedural Terrain\Procedural Terrain\GLFW.lib(win32_window.obj) Procedural Terrain
Error 13 error LNK2019: unresolved external symbol __imp_DestroyWindow referenced in function destroyWindow C:\Users\Asher\documents\visual studio 2012\Projects\Procedural Terrain\Procedural Terrain\GLFW.lib(win32_window.obj) Procedural Terrain
Error 14 error LNK2019: unresolved external symbol __imp_ShowWindow referenced in function _glfwPlatformIconifyWindow C:\Users\Asher\documents\visual studio 2012\Projects\Procedural Terrain\Procedural Terrain\GLFW.lib(win32_window.obj) Procedural Terrain
Error 15 error LNK2019: unresolved external symbol __imp_SetWindowPos referenced in function _glfwPlatformOpenWindow C:\Users\Asher\documents\visual studio 2012\Projects\Procedural Terrain\Procedural Terrain\GLFW.lib(win32_window.obj) Procedural Terrain
Error 16 error LNK2019: unresolved external symbol __imp_BringWindowToTop referenced in function setForegroundWindow C:\Users\Asher\documents\visual studio 2012\Projects\Procedural Terrain\Procedural Terrain\GLFW.lib(win32_window.obj) Procedural Terrain
Error 17 error LNK2019: unresolved external symbol __imp_CharUpperA referenced in function translateKey C:\Users\Asher\documents\visual studio 2012\Projects\Procedural Terrain\Procedural Terrain\GLFW.lib(win32_window.obj) Procedural Terrain
Error 18 error LNK2019: unresolved external symbol __imp_CharUpperW referenced in function translateKey C:\Users\Asher\documents\visual studio 2012\Projects\Procedural Terrain\Procedural Terrain\GLFW.lib(win32_window.obj) Procedural Terrain
Error 19 error LNK2019: unresolved external symbol __imp_SetFocus referenced in function _glfwPlatformOpenWindow C:\Users\Asher\documents\visual studio 2012\Projects\Procedural Terrain\Procedural Terrain\GLFW.lib(win32_window.obj) Procedural Terrain
Error 20 error LNK2019: unresolved external symbol __imp_GetAsyncKeyState referenced in function _glfwPlatformPollEvents C:\Users\Asher\documents\visual studio 2012\Projects\Procedural Terrain\Procedural Terrain\GLFW.lib(win32_window.obj) Procedural Terrain
Error 21 error LNK2019: unresolved external symbol __imp_GetKeyboardState referenced in function translateChar C:\Users\Asher\documents\visual studio 2012\Projects\Procedural Terrain\Procedural Terrain\GLFW.lib(win32_window.obj) Procedural Terrain
Error 22 error LNK2019: unresolved external symbol __imp_ToAscii referenced in function translateChar C:\Users\Asher\documents\visual studio 2012\Projects\Procedural Terrain\Procedural Terrain\GLFW.lib(win32_window.obj) Procedural Terrain
Error 23 error LNK2019: unresolved external symbol __imp_ToUnicode referenced in function translateChar C:\Users\Asher\documents\visual studio 2012\Projects\Procedural Terrain\Procedural Terrain\GLFW.lib(win32_window.obj) Procedural Terrain
Error 24 error LNK2019: unresolved external symbol __imp_MapVirtualKeyA referenced in function translateKey C:\Users\Asher\documents\visual studio 2012\Projects\Procedural Terrain\Procedural Terrain\GLFW.lib(win32_window.obj) Procedural Terrain
Error 25 error LNK2019: unresolved external symbol __imp_SetCapture referenced in function _glfwPlatformHideMouseCursor C:\Users\Asher\documents\visual studio 2012\Projects\Procedural Terrain\Procedural Terrain\GLFW.lib(win32_window.obj) Procedural Terrain
Error 26 error LNK2019: unresolved external symbol __imp_ReleaseCapture referenced in function _glfwPlatformShowMouseCursor C:\Users\Asher\documents\visual studio 2012\Projects\Procedural Terrain\Procedural Terrain\GLFW.lib(win32_window.obj) Procedural Terrain
Error 27 error LNK2019: unresolved external symbol __imp_GetForegroundWindow referenced in function setForegroundWindow C:\Users\Asher\documents\visual studio 2012\Projects\Procedural Terrain\Procedural Terrain\GLFW.lib(win32_window.obj) Procedural Terrain
一直到错误 50,然后...
Error 51 error LNK1120: 46 unresolved externals C:\Users\Asher\documents\visual studio 2012\Projects\Procedural Terrain\x64\Debug\Procedural Terrain.exe Procedural Terrain
我看到这些错误并注意到最后的“win32”。我正在使用 64 位系统、64 位项目(由解决方案平台声明)和 GLFW 的 64 位二进制下载。GLFW 常见问题页面描述的“未解析的外部符号”错误表明链接问题是导致此问题的原因。但是,我相信我已经为静态库正确链接了所有内容。这是我所做的。
在 Project>Properties>Configuration Properties>Linker>Input>Additional Dependencies 下,我添加了 GLFW.lib opengl32.lib 和 glu32.lib
在 VC++ 目录>包含目录下,我添加了 C:\Users\Asher\glfw-2.7.7.bin.WIN64\glfw-2.7.7.bin.WIN64\include 。
在 VC++ 目录>库目录下,我添加了 C:\Users\Asher\glfw-2.7.7.bin.WIN64\glfw-2.7.7.bin.WIN64\lib-msvc110 。
我没有碰过 dll,因为我更喜欢静态库。另外,这是我的代码
#include "Header.h"
using namespace std;
int main(int argc, char **argv){
//Initializes non-window dependent sources.
if (!glfwInit())
{
cout<< "Failed to initialize GLFW";
return -1;
}
//Sets window parameters
glfwOpenWindow(0, 0, 0, 0, 0,
0, 8, 0, GLFW_FULLSCREEN);
//Window name
glfwSetWindowTitle("The GLFW Window");
//Terminates GLFW.
glfwTerminate();
return 0;
}
标题包含
#include <IOstream>
#include <GL\glfw.h>
到目前为止,关于该主题的任何主题都没有任何帮助,我很困惑!对此问题的解决方案将不胜感激。- Asher(从我的文件路径中可以看出 =D)