Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
360 views
in Technique[技术] by (71.8m points)

c++ - VC++ LNK Errors With GLFW

I'm using VC++ 2010 to work with some OpenGL. However, it's becoming a pain. I keep getting error codes again and again.

Here is the code I am working with:

// Include standard headers
#include <stdio.h>
#include <stdlib.h>


// Include GLEW
#include <GL/glew.h>

// Include GLFW
#include <GL/glfw.h>


// Include GLM
#include <glm/glm.hpp>
using namespace glm;
int main( void ){        
    // Initialise GLFW
    if( !glfwInit() ){

            fprintf( stderr, "Failed to initialize GLFW
" );
            return -1;
    }

    glfwOpenWindowHint(GLFW_FSAA_SAMPLES, 4);
    glfwOpenWindowHint(GLFW_OPENGL_VERSION_MAJOR, 3);
    glfwOpenWindowHint(GLFW_OPENGL_VERSION_MINOR, 3);
    glfwOpenWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);

    // Open a window and create its OpenGL context
    if( !glfwOpenWindow( 1024, 768, 0,0,0,0, 32,0, GLFW_WINDOW ) )
    {
            fprintf( stderr, "Failed to open GLFW window. If you have an Intel GPU, they are not 3.3 compatible. Try the 2.1 version of the tutorials.
" );
            glfwTerminate();
            return -1;
    }

    // Initialize GLEW
    if (glewInit() != GLEW_OK) {
            fprintf(stderr, "Failed to initialize GLEW
");
            return -1;
    }

    glfwSetWindowTitle( "Tutorial 01" );

    // Ensure we can capture the escape key being pressed below
    glfwEnable( GLFW_STICKY_KEYS );

    // Dark blue background
    glClearColor(0.0f, 0.0f, 0.3f, 0.0f);

    do{
         // Draw nothing, see you in tutorial 2 !

         // Swap buffers
         glfwSwapBuffers();

    } // Check if the ESC key was pressed or the window was closed
    while( glfwGetKey( GLFW_KEY_ESC ) != GLFW_PRESS &&
         glfwGetWindowParam( GLFW_OPENED ) );

// Close OpenGL window and terminate GLFW
    glfwTerminate();
    return 0;
}

Here are the errors I am getting from Visual Studio after compiling the code above. The output appears to be linking issues, however, I'm not sure how to correctly link the glfw requirements with the editor. Example errors:

Error   52  error LNK1120: 10 unresolved externals  C:UsersUsernamedocumentsvisual studio 2010ProjectsOpenGL FunDebugOpenGL Fun.exe OpenGL Fun
Error   42  error LNK2001: unresolved external symbol __imp__glClear@4  C:UsersUsernamedocumentsvisual studio 2010ProjectsOpenGL FunOpenGL FunGLFW.lib(win32_window.obj)    OpenGL Fun
Error   39  error LNK2001: unresolved external symbol __imp__glClearColor@16    C:UsersUsernamedocumentsvisual studio 2010ProjectsOpenGL FunOpenGL FunGLFW.lib(win32_window.obj)    OpenGL Fun
Error   50  error LNK2001: unresolved external symbol __imp__glGetIntegerv@8    C:UsersUsernamedocumentsvisual studio 2010ProjectsOpenGL FunOpenGL FunGLFW.lib(glext.obj)   OpenGL Fun
Error   45  error LNK2001: unresolved external symbol __imp__wglGetProcAddress@4    C:UsersUsernamedocumentsvisual studio 2010ProjectsOpenGL FunOpenGL FunGLFW.lib(win32_glext.obj) OpenGL Fun
Error   41  error LNK2019: unresolved external symbol __imp__glClear@4 referenced in function _glfwOpenWindow   C:UsersUsernamedocumentsvisual studio 2010ProjectsOpenGL FunOpenGL FunGLFW.lib(window.obj)  OpenGL Fun
Error   38  error LNK2019: unresolved external symbol __imp__glClearColor@16 referenced in function _main   C:UsersUsernamedocumentsvisual studio 2010ProjectsOpenGL FunOpenGL FunMain.obj  OpenGL Fun
Error   40  error LNK2019: unresolved external symbol __imp__glewInit@0 referenced in function _main    C:UsersUsernamedocumentsvisual studio 2010ProjectsOpenGL FunOpenGL FunMain.obj  OpenGL Fun
Error   48  error LNK2019: unresolved external symbol __imp__glGetFloatv@8 referenced in function __glfwPlatformSetWindowSize   C:UsersUsernamedocumentsvisual studio 2010ProjectsOpenGL FunOpenGL FunGLFW.lib(win32_window.obj)    OpenGL Fun
Error   49  error LNK2019: unresolved external symbol __imp__glGetIntegerv@8 referenced in function __glfwPlatformSetWindowSize C:UsersUsernamedocumentsvisual studio 2010ProjectsOpenGL FunOpenGL FunGLFW.lib(win32_window.obj)    OpenGL Fun
Error   51  error LNK2019: unresolved external symbol __imp__glGetString@4 referenced in function __glfwParseGLVersion  C:UsersUsernamedocumentsvisual studio 2010ProjectsOpenGL FunOpenGL FunGLFW.lib(glext.obj)   OpenGL Fun
Error   43  error LNK2019: unresolved external symbol __imp__wglCreateContext@4 referenced in function _createContext   C:UsersUsernamedocumentsvisual studio 2010ProjectsOpenGL FunOpenGL FunGLFW.lib(win32_window.obj)    OpenGL Fun
Error   47  error LNK2019: unresolved external symbol __imp__wglDeleteContext@4 referenced in function _destroyWindow   C:UsersUsernamedocumentsvisual studio 2010ProjectsOpenGL FunOpenGL FunGLFW.lib(win32_window.obj)    OpenGL Fun
Error   44  error LNK2019: unresolved external symbol __imp__wglGetProcAddress@4 referenced in function _initWGLExtensions  C:UsersUsernamedocumentsvisual studio 2010ProjectsOpenGL FunOpenGL FunGLFW.lib(win32_window.obj)    OpenGL Fun
Error   46  error LNK2019: unresolved external symbol __imp__wglMakeCurrent@8 referenced in function _createWindow  C:UsersUsernamedocumentsvisual studio 2010ProjectsOpenGL FunOpenGL FunGLFW.lib(win32_window.obj)    OpenGL Fun
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

In the solution explorer, right-click your project and select properties. From the configuration list box, select "all configurations". In the left pane, select the Linker sub-tree and then the input option. Add opengl32.lib under "Additional Dependencies".


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...