简体   繁体   中英

GLFW - Problems Linking with Visual Studio 2012

I am running into a large problem with linking GLFW. I have seen multiple posts on this site and other sites where such error messages have been looked at, yet when I try the fixes, the errors remain the same. The errors in particular are:

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

All the way up to Error 50, and then...

Error   51  error LNK1120: 46 unresolved externals  C:\Users\Asher\documents\visual studio 2012\Projects\Procedural Terrain\x64\Debug\Procedural Terrain.exe    Procedural Terrain

I see these errors and notice the "win32" at the end. I am using a 64 bit system, a 64 bit project (as declared by the solution platform), and the 64 bit binary download for GLFW. The error for the "unresolved external symbol" as described by the GLFW FAQ page says that linking problems are the cause of this. However, I believe I have linked everything properly for the static library. Here is what I have done.

  1. Under Project>Properties>Configuration Properties>Linker>Input>Additional Dependencies, I have added GLFW.lib opengl32.lib and glu32.lib

  2. Under VC++ Directories>Include Directories I added C:\\Users\\Asher\\glfw-2.7.7.bin.WIN64\\glfw-2.7.7.bin.WIN64\\include .

  3. Under VC++ Directories>Library Directories I added C:\\Users\\Asher\\glfw-2.7.7.bin.WIN64\\glfw-2.7.7.bin.WIN64\\lib-msvc110 .

I have not touched the dll as I would prefer a static library. Also, here is my code

#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;
}

The header contains

#include <IOstream>
#include <GL\glfw.h>

No topics so far on the subject have been any help and I am quite stuck! A solution to this problem would be much appreciated. - Asher (as you can tell from my file paths =D)

To give a short overview how to debug such a problem if other people stumble upon similar problems:

First thing you'll notice is that all linker errors refer to functions in the win32 library. Therefore we first try to call one of those functions directly and see if it changes anything.

As expected that didn't change anything which meant we had a problem with linking user32.lib . Since a default Visual Studio project shouldn't have this problem, this either meant the complete install had a problem or only the specific solution. Creating a new solution solved the problem, but if not the next thing would've been to reinstall Visual Studio.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM