gpt4 book ai didi

c++ - GLFW - 与 Visual Studio 2012 的链接问题

转载 作者:太空宇宙 更新时间:2023-11-04 12:00:17 25 4
gpt4 key购买 nike

我在链接 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 FAQ 页面中描述的“未解析的外部符号”错误表明链接问题是造成这种情况的原因。但是,我相信我已经为静态库正确链接了所有内容。这是我所做的。

  1. 在Project>Properties>Configuration Properties>Linker>Input>Additional Dependencies下,我已经添加了GLFW.libopengl32.lib 和glu32.lib

  2. 在 VC++ Directories>Include Directories 下,我添加了 C:\Users\Asher\glfw-2.7.7.bin.WIN64\glfw-2.7.7.bin.WIN64\include 。

  3. 在 VC++ Directories>Library Directories 下,我添加了 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)

最佳答案

简要概述如果其他人偶然发现类似问题,如何调试此类问题:

首先您会注意到所有链接器错误都与 win32 库中的函数有关。因此,我们首先尝试直接调用其中一个函数,看看它是否改变了什么。

正如预期的那样,这并没有改变任何东西,这意味着我们在链接 user32.lib 时遇到了问题。由于默认的 Visual Studio 项目不应该有这个问题,这意味着完整的安装有问题或只有特定的解决方案。创建一个新的解决方案解决了这个问题,但如果没有,下一步就是重新安装 Visual Studio。

关于c++ - GLFW - 与 Visual Studio 2012 的链接问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14418537/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com