OpenGL program compilation error
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Thread: OpenGL program compilation error

  1. #1
    Join Date
    Oct 2017
    Posts
    17

    OpenGL program compilation error

    Can some help me I got hundreds error when try to compile this.

    Code:
    #include <glad/glad.h>
    #include <GLFW/glfw3.h>
    
    #include <iostream>
    
    void framebuffer_size_callback(GLFWwindow* window, int width, int height);
    void processInput(GLFWwindow *window);
    
    // settings
    const unsigned int SCR_WIDTH = 800;
    const unsigned int SCR_HEIGHT = 600;
    
    int main()
    {
        // glfw: initialize and configure
        // ------------------------------
        glfwInit();
        glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
        glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
        glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
    
    #ifdef __APPLE__
        glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE); // uncomment this statement to fix compilation on OS X
    #endif
    
        // glfw window creation
        // --------------------
        GLFWwindow* window = glfwCreateWindow(SCR_WIDTH, SCR_HEIGHT, "LearnOpenGL", NULL, NULL);
        if (window == NULL)
        {
            std::cout << "Failed to create GLFW window" << std::endl;
            glfwTerminate();
            return -1;
        }
        glfwMakeContextCurrent(window);
        glfwSetFramebufferSizeCallback(window, framebuffer_size_callback);
    
        // glad: load all OpenGL function pointers
        // ---------------------------------------
        if (!gladLoadGLLoader((GLADloadproc)glfwGetProcAddress))
        {
            std::cout << "Failed to initialize GLAD" << std::endl;
            return -1;
        }    
    
        // render loop
        // -----------
        while (!glfwWindowShouldClose(window))
        {
            // input
            // -----
            processInput(window);
    
            // render
            // ------
            glClearColor(0.2f, 0.3f, 0.3f, 1.0f);
            glClear(GL_COLOR_BUFFER_BIT);
    
            // glfw: swap buffers and poll IO events (keys pressed/released, mouse moved etc.)
            // -------------------------------------------------------------------------------
            glfwSwapBuffers(window);
            glfwPollEvents();
        }
    
        // glfw: terminate, clearing all previously allocated GLFW resources.
        // ------------------------------------------------------------------
        glfwTerminate();
        return 0;
    }
    
    // process all input: query GLFW whether relevant keys are pressed/released this frame and react accordingly
    // ---------------------------------------------------------------------------------------------------------
    void processInput(GLFWwindow *window)
    {
        if(glfwGetKey(window, GLFW_KEY_ESCAPE) == GLFW_PRESS)
            glfwSetWindowShouldClose(window, true);
    }
    
    // glfw: whenever the window size changed (by OS or user resize) this callback function executes
    // ---------------------------------------------------------------------------------------------
    void framebuffer_size_callback(GLFWwindow* window, int width, int height)
    {
        // make sure the viewport matches the new window dimensions; note that width and 
        // height will be significantly larger than specified on retina displays.
        glViewport(0, 0, width, height);
    }
    Code:
    Source.cpp
    c:\program files (x86)\windows kits\8.1\include\um\gl\gl.h(107): warning C4005: 'GL_ALL_ATTRIB_BITS' : macro redefinition
              c:\users\balma alparisi\documents\visual studio 2013\opengl library\glad\include\glad\glad.h(378) : see previous definition of 'GL_ALL_ATTRIB_BITS'
    c:\program files (x86)\windows kits\8.1\include\um\gl\gl.h(973): warning C4005: 'GL_CLIENT_ALL_ATTRIB_BITS' : macro redefinition
              c:\users\balma alparisi\documents\visual studio 2013\opengl library\glad\include\glad\glad.h(644) : see previous definition of 'GL_CLIENT_ALL_ATTRIB_BITS'
    c:\program files (x86)\windows kits\8.1\include\um\gl\gl.h(1152): warning C4005: 'GL_LOGIC_OP' : macro redefinition
              c:\users\balma alparisi\documents\visual studio 2013\opengl library\glad\include\glad\glad.h(466) : see previous definition of 'GL_LOGIC_OP'
    c:\program files (x86)\windows kits\8.1\include\um\gl\gl.h(1153): warning C4005: 'GL_TEXTURE_COMPONENTS' : macro redefinition
              c:\users\balma alparisi\documents\visual studio 2013\opengl library\glad\include\glad\glad.h(550) : see previous definition of 'GL_TEXTURE_COMPONENTS'
    c:\program files (x86)\windows kits\8.1\include\um\gl\gl.h(1157): error C2365: 'glad_glAccum' : redefinition; previous definition was 'data variable'
              c:\users\balma alparisi\documents\visual studio 2013\opengl library\glad\include\glad\glad.h(2708) : see declaration of 'glad_glAccum'
    c:\program files (x86)\windows kits\8.1\include\um\gl\gl.h(1158): error C2365: 'glad_glAlphaFunc' : redefinition; previous definition was 'data variable'
              c:\users\balma alparisi\documents\visual studio 2013\opengl library\glad\include\glad\glad.h(2777) : see declaration of 'glad_glAlphaFunc'
    c:\program files (x86)\windows kits\8.1\include\um\gl\gl.h(1159): error C2365: 'glad_glAreTexturesResident' : redefinition; previous definition was 'data variable'
              c:\users\balma alparisi\documents\visual studio 2013\opengl library\glad\include\glad\glad.h(2982) : see declaration of 'glad_glAreTexturesResident'
    c:\program files (x86)\windows kits\8.1\include\um\gl\gl.h(1160): error C2365: 'glad_glArrayElement' : redefinition; previous definition was 'data variable'
              c:\users\balma alparisi\documents\visual studio 2013\opengl library\glad\include\glad\glad.h(2952) : see declaration of 'glad_glArrayElement'
    c:\program files (x86)\windows kits\8.1\include\um\gl\gl.h(1161): error C2365: 'glad_glBegin' : redefinition; previous definition was 'data variable'
              c:\users\balma alparisi\documents\visual studio 2013\opengl library\glad\include\glad\glad.h(2153) : see declaration of 'glad_glBegin'
    c:\program files (x86)\windows kits\8.1\include\um\gl\gl.h(1162): error C2365: 'glad_glBindTexture' : redefinition; previous definition was 'data variable'
              c:\users\balma alparisi\documents\visual studio 2013\opengl library\glad\include\glad\glad.h(2940) : see declaration of 'glad_glBindTexture'
    c:\program files (x86)\windows kits\8.1\include\um\gl\gl.h(1163): error C2365: 'glad_glBitmap' : redefinition; previous definition was 'data variable'
              c:\users\balma alparisi\documents\visual studio 2013\opengl library\glad\include\glad\glad.h(2156) : see declaration of 'glad_glBitmap'
    c:\program files (x86)\windows kits\8.1\include\um\gl\gl.h(1164): error C2365: 'glad_glBlendFunc' : redefinition; previous definition was 'data variable'
              c:\users\balma alparisi\documents\visual studio 2013\opengl library\glad\include\glad\glad.h(2063) : see declaration of 'glad_glBlendFunc'
    c:\program files (x86)\windows kits\8.1\include\um\gl\gl.h(1165): error C2365: 'glad_glCallList' : redefinition; previous definition was 'data variable'
              c:\users\balma alparisi\documents\visual studio 2013\opengl library\glad\include\glad\glad.h(2138) : see declaration of 'glad_glCallList'
    c:\program files (x86)\windows kits\8.1\include\um\gl\gl.h(1166): error C2365: 'glad_glCallLists' : redefinition; previous definition was 'data variable'
              c:\users\balma alparisi\documents\visual studio 2013\opengl library\glad\include\glad\glad.h(2141) : see declaration of 'glad_glCallLists'
    c:\program files (x86)\windows kits\8.1\include\um\gl\gl.h(1167): error C2365: 'glad_glClear' : redefinition; previous definition was 'data variable'
              c:\users\balma alparisi\documents\visual studio 2013\opengl library\glad\include\glad\glad.h(2030) : see declaration of 'glad_glClear'
    c:\program files (x86)\windows kits\8.1\include\um\gl\gl.h(1168): error C2365: 'glad_glClearAccum' : redefinition; previous definition was 'data variable'
              c:\users\balma alparisi\documents\visual studio 2013\opengl library\glad\include\glad\glad.h(2699) : see declaration of 'glad_glClearAccum'
    c:\program files (x86)\windows kits\8.1\include\um\gl\gl.h(1169): error C2365: 'glad_glClearColor' : redefinition; previous definition was 'data variable'
              c:\users\balma alparisi\documents\visual studio 2013\opengl library\glad\include\glad\glad.h(2033) : see declaration of 'glad_glClearColor'
    c:\program files (x86)\windows kits\8.1\include\um\gl\gl.h(1170): error C2365: 'glad_glClearDepth' : redefinition; previous definition was 'data variable'
              c:\users\balma alparisi\documents\visual studio 2013\opengl library\glad\include\glad\glad.h(2039) : see declaration of 'glad_glClearDepth'
    c:\program files (x86)\windows kits\8.1\include\um\gl\gl.h(1171): error C2365: 'glad_glClearIndex' : redefinition; previous definition was 'data variable'
              c:\users\balma alparisi\documents\visual studio 2013\opengl library\glad\include\glad\glad.h(2702) : see declaration of 'glad_glClearIndex'
    c:\program files (x86)\windows kits\8.1\include\um\gl\gl.h(1172): error C2365: 'glad_glClearStencil' : redefinition; previous definition was 'data variable'
              c:\users\balma alparisi\documents\visual studio 2013\opengl library\glad\include\glad\glad.h(2036) : see declaration of 'glad_glClearStencil'
    c:\program files (x86)\windows kits\8.1\include\um\gl\gl.h(1173): error C2365: 'glad_glClipPlane' : redefinition; previous definition was 'data variable'
              c:\users\balma alparisi\documents\visual studio 2013\opengl library\glad\include\glad\glad.h(2582) : see declaration of 'glad_glClipPlane'
    c:\program files (x86)\windows kits\8.1\include\um\gl\gl.h(1174): error C2365: 'glad_glColor3b' : redefinition; previous definition was 'data variable'
              c:\users\balma alparisi\documents\visual studio 2013\opengl library\glad\include\glad\glad.h(2159) : see declaration of 'glad_glColor3b'
    c:\program files (x86)\windows kits\8.1\include\um\gl\gl.h(1175): error C2365: 'glad_glColor3bv' : redefinition; previous definition was 'data variable'
              c:\users\balma alparisi\documents\visual studio 2013\opengl library\glad\include\glad\glad.h(2162) : see declaration of 'glad_glColor3bv'
    c:\program files (x86)\windows kits\8.1\include\um\gl\gl.h(1176): error C2365: 'glad_glColor3d' : redefinition; previous definition was 'data variable'
              c:\users\balma alparisi\documents\visual studio 2013\opengl library\glad\include\glad\glad.h(2165) : see declaration of 'glad_glColor3d'
    c:\program files (x86)\windows kits\8.1\include\um\gl\gl.h(1177): error C2365: 'glad_glColor3dv' : redefinition; previous definition was 'data variable'
              c:\users\balma alparisi\documents\visual studio 2013\opengl library\glad\include\glad\glad.h(2168) : see declaration of 'glad_glColor3dv'
    c:\program files (x86)\windows kits\8.1\include\um\gl\gl.h(1178): error C2365: 'glad_glColor3f' : redefinition; previous definition was 'data variable'
              c:\users\balma alparisi\documents\visual studio 2013\opengl library\glad\include\glad\glad.h(2171) : see declaration of 'glad_glColor3f'
    c:\program files (x86)\windows kits\8.1\include\um\gl\gl.h(1179): error C2365: 'glad_glColor3fv' : redefinition; previous definition was 'data variable'
              c:\users\balma alparisi\documents\visual studio 2013\opengl library\glad\include\glad\glad.h(2174) : see declaration of 'glad_glColor3fv'
    c:\program files (x86)\windows kits\8.1\include\um\gl\gl.h(1180): error C2365: 'glad_glColor3i' : redefinition; previous definition was 'data variable'
              c:\users\balma alparisi\documents\visual studio 2013\opengl library\glad\include\glad\glad.h(2177) : see declaration of 'glad_glColor3i'
    c:\program files (x86)\windows kits\8.1\include\um\gl\gl.h(1181): error C2365: 'glad_glColor3iv' : redefinition; previous definition was 'data variable'
              c:\users\balma alparisi\documents\visual studio 2013\opengl library\glad\include\glad\glad.h(2180) : see declaration of 'glad_glColor3iv'
    c:\program files (x86)\windows kits\8.1\include\um\gl\gl.h(1182): error C2365: 'glad_glColor3s' : redefinition; previous definition was 'data variable'
              c:\users\balma alparisi\documents\visual studio 2013\opengl library\glad\include\glad\glad.h(2183) : see declaration of 'glad_glColor3s'
    c:\program files (x86)\windows kits\8.1\include\um\gl\gl.h(1183): error C2365: 'glad_glColor3sv' : redefinition; previous definition was 'data variable'
              c:\users\balma alparisi\documents\visual studio 2013\opengl library\glad\include\glad\glad.h(2186) : see declaration of 'glad_glColor3sv'
    c:\program files (x86)\windows kits\8.1\include\um\gl\gl.h(1184): error C2365: 'glad_glColor3ub' : redefinition; previous definition was 'data variable'
              c:\users\balma alparisi\documents\visual studio 2013\opengl library\glad\include\glad\glad.h(2189) : see declaration of 'glad_glColor3ub'
    c:\program files (x86)\windows kits\8.1\include\um\gl\gl.h(1185): error C2365: 'glad_glColor3ubv' : redefinition; previous definition was 'data variable'
              c:\users\balma alparisi\documents\visual studio 2013\opengl library\glad\include\glad\glad.h(2192) : see declaration of 'glad_glColor3ubv'
    c:\program files (x86)\windows kits\8.1\include\um\gl\gl.h(1186): error C2365: 'glad_glColor3ui' : redefinition; previous definition was 'data variable'
    I'm not a Computer Science student, I'm an Electrical Engineering student but I love programming.

  2. #2
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Wallisellen (ZH), Switzerland
    Posts
    19,012

    Re: OpenGL program compilation error

    Did you try something like was recommended here?
    Victor Nijegorodov

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This a Codeguru.com survey!


On-Demand Webinars (sponsored)