Menu

GLFW and Dev-cpp (long post)

2006-03-21
2012-09-26
  • Nobody/Anonymous

    I have just used the update/package tools to
    install GLFW V 2.5, and some google search references I found state that the upgrade
    process compiles and sets up GLFW for you.
    This is obviously not the case since when I
    try to compile anything I get a lot of errors
    as below. (the actual code I tried to compile
    is at the end of this post)
    Compiler: Default compiler
    Executing gcc.exe...
    gcc.exe "C:\dev\examples\mipmaps.c" -o "C:\dev\examples\mipmaps.exe" -I"C:\DEV-CPP\include" -L"C:\DEV-CPP\lib" -lglut32 -lopengl32 -lglfw -lglu32 -luser32 -lkernel32 -DLFW.DLL
    <command line>:1:4: warning: ISO C requires whitespace after the macro name

    C:\DEV-CPP\lib/libglfw.a(image.o)(.text+0x460):image.c: undefined reference to glGetIntegerv@8' C:\DEV-CPP\lib/libglfw.a(image.o)(.text+0x473):image.c: undefined reference toglPixelStorei@8'
    C:\DEV-CPP\lib/libglfw.a(image.o)(.text+0x4af):image.c: undefined reference to glGetTexParameteriv@12' C:\DEV-CPP\lib/libglfw.a(image.o)(.text+0x539):image.c: undefined reference toglTexImage2D@36'
    C:\DEV-CPP\lib/libglfw.a(image.o)(.text+0x66c):image.c: undefined reference to glPixelStorei@8' C:\DEV-CPP\lib/libglfw.a(win32_window.o)(.text+0x97f):win32_window.c: undefined reference towglMakeCurrent@8'
    C:\DEV-CPP\lib/libglfw.a(win32_window.o)(.text+0x98a):win32_window.c: undefined reference to wglDeleteContext@4' C:\DEV-CPP\lib/libglfw.a(win32_window.o)(.text+0xcca):win32_window.c: undefined reference towglCreateContext@4'
    C:\DEV-CPP\lib/libglfw.a(win32_window.o)(.text+0xcdf):win32_window.c: undefined reference to wglMakeCurrent@8' C:\DEV-CPP\lib/libglfw.a(win32_window.o)(.text+0xd44):win32_window.c: undefined reference toglGetString@4'
    C:\DEV-CPP\lib/libglfw.a(win32_window.o)(.text+0xd72):win32_window.c: undefined reference to wglGetProcAddress@4' C:\DEV-CPP\lib/libglfw.a(win32_window.o)(.text+0xe8e):win32_window.c: undefined reference toglGetIntegerv@8'
    C:\DEV-CPP\lib/libglfw.a(win32_window.o)(.text+0xe9c):win32_window.c: undefined reference to glGetFloatv@8' C:\DEV-CPP\lib/libglfw.a(glext.o)(.text+0x91):glext.c: undefined reference toglGetString@4'
    C:\DEV-CPP\lib/libglfw.a(glext.o)(.text+0x109):glext.c: undefined reference to glGetString@4' C:\DEV-CPP\lib/libglfw.a(win32_glext.o)(.text+0xd):win32_glext.c: undefined reference towglGetProcAddress@4'
    C:\DEV-CPP\lib/libglfw.a(win32_glext.o)(.text+0x33):win32_glext.c: undefined reference to wglGetProcAddress@4' C:\DEV-CPP\lib/libglfw.a(win32_glext.o)(.text+0x69):win32_glext.c: undefined reference towglGetProcAddress@4'
    collect2: ld returned 1 exit status
    Execution terminated

    I looked over the docs and followed a few steps:
    since I am running win 98 I edited the toplevel
    makefile as instructed in the readme.
    I downloaded and extracted glfw-2.5 to another
    folder, set in my path SET PATH=%PATH%; C:\Dev-Cpp\bin\ and ran the make win32-mgw
    command with the path of the root folder.
    This just caused a dos window to appear and disappear and nothing else. I have spent the better part of two days doing searches for
    halfway decent instructions on how to compile
    gflw for Dev-cpp. Can anyone point me to any detailed instructions?

    The source code itself:
    //========================================================================
    // This is a small test application for GLFW.
    // The program shows texture loading with mipmap generation and trilienar
    // filtering.
    // Note: For OpenGL 1.0 compability, we do not use texture objects (this
    // is no issue, since we only have one texture).
    //========================================================================

    /**********
    * $Id: mipmaps.c,v 1.3 2004/02/25 22:36:32 marcus256 Exp $
    **********/

    include <stdio.h>

    include <GL/glfw.h>

    //========================================================================
    // main()
    //========================================================================

    int main( void )
    {
    int width, height, running, frames, x, y;
    double t, t0, fps;
    char titlestr[ 200 ];

    // Initialise GLFW
    glfwInit();
    
    // Open OpenGL window
    if( !glfwOpenWindow( 640, 480, 0,0,0,0, 0,0, GLFW_WINDOW ) )
    {
        glfwTerminate();
        return 0;
    }
    
    // Enable sticky keys
    glfwEnable( GLFW_STICKY_KEYS );
    
    // Disable vertical sync (on cards that support it)
    glfwSwapInterval( 0 );
    
    // Load texture from file, and build all mipmap levels. The
    // texture is automatically uploaded to texture memory.
    if( !glfwLoadTexture2D( &quot;mipmaps.tga&quot;, GLFW_BUILD_MIPMAPS_BIT ) )
    {
        glfwTerminate();
        return 0;
    }
    
    // Use trilinear interpolation (GL_LINEAR_MIPMAP_LINEAR)
    glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,
                     GL_LINEAR_MIPMAP_LINEAR );
    glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER,
                     GL_LINEAR );
    
    // Enable texturing
    glEnable( GL_TEXTURE_2D );
    
    // Main loop
    running = GL_TRUE;
    frames = 0;
    t0 = glfwGetTime();
    while( running )
    {
        // Get time and mouse position
        t = glfwGetTime();
        glfwGetMousePos( &amp;x, &amp;y );
    
        // Calculate and display FPS (frames per second)
        if( (t-t0) &gt; 1.0 || frames == 0 )
        {
            fps = (double)frames / (t-t0);
            sprintf( titlestr, &quot;Trilinear interpolation (%.1f FPS)&quot;, fps );
            glfwSetWindowTitle( titlestr );
            t0 = t;
            frames = 0;
        }
        frames ++;
    
        // Get window size (may be different than the requested size)
        glfwGetWindowSize( &amp;width, &amp;height );
        height = height &gt; 0 ? height : 1;
    
        // Set viewport
        glViewport( 0, 0, width, height );
    
        // Clear color buffer
        glClearColor( 0.0f, 0.0f, 0.0f, 0.0f);
        glClear( GL_COLOR_BUFFER_BIT );
    
        // Select and setup the projection matrix
        glMatrixMode( GL_PROJECTION );
        glLoadIdentity();
        gluPerspective( 65.0f, (GLfloat)width/(GLfloat)height, 1.0f,
            50.0f );
    
        // Select and setup the modelview matrix
        glMatrixMode( GL_MODELVIEW );
        glLoadIdentity();
        gluLookAt( 0.0f,  3.0f, -20.0f,    // Eye-position
                   0.0f, -4.0f, -11.0f,    // View-point
                   0.0f,  1.0f,   0.0f );  // Up-vector
    
        // Draw a textured quad
        glRotatef( 0.05*(GLfloat)x + (GLfloat)t*5.0f, 0.0f, 1.0f, 0.0f );
        glBegin( GL_QUADS );
          glTexCoord2f( -20.0f,  20.0f );
          glVertex3f( -50.0f, 0.0f, -50.0f );
          glTexCoord2f(  20.0f,  20.0f );
          glVertex3f(  50.0f, 0.0f, -50.0f );
          glTexCoord2f(  20.0f, -20.0f );
          glVertex3f(  50.0f, 0.0f,  50.0f );
          glTexCoord2f( -20.0f, -20.0f );
          glVertex3f( -50.0f, 0.0f,  50.0f );
        glEnd();
    
        // Swap buffers
        glfwSwapBuffers();
    
        // Check if the ESC key was pressed or the window was closed
        running = !glfwGetKey( GLFW_KEY_ESC ) &amp;&amp;
                  glfwGetWindowParam( GLFW_OPENED );
    }
    
    // Close OpenGL window and terminate GLFW
    glfwTerminate();
    
    return 0;
    

    }

     
    • Anonymous

      Anonymous - 2006-03-21

      You are not clear how you are executing the build command, but say that it "caused a dos window to appear and disappear". This should not happen is you explicitly open a command prompt window and type the command name in manually - teh window qill remain, and any error messages may be read.

      It is unusual for a DevPak to be delivered only as source and require a library build - but I am not familiar with that particular product. The compile log you posted would be expected if the library does not exist (because it was not yet built).

      If it fails and you need assistance, a transcript of the console session might be helpful. Text may be copied from a console window by right-click->edit->mark, select the text and press enter. It may then be pasted directly into the forum. (not sure it is that flexible in Win98 however)

      Clifford

       
    • Nobody/Anonymous

      as far as the original undefined references go you should have noticed the problem immediately. we have argued about proper fixes a few times.

      "gcc.exe "C:\dev\examples\mipmaps.c" -o "C:\dev\examples\mipmaps.exe" -I"C:\DEV-CPP\include" -L"C:\DEV-CPP\lib" -lglut32 -lopengl32 -lglfw -lglu32 -luser32 -lkernel32 -DLFW.DLL"

      the "glfw" library clearly depends on "opengl32" but he has "opengl32" specified before the "glfw" part.

      try adding an additional "-lopengl32" after the "-lglfw" part.

      "The compile log you posted would be expected if the library does not exist (because it was not yet built)."

      it references particular objects of the library which would be impossible if the library had been unavailable.

      snork

       
      • Anonymous

        Anonymous - 2006-03-21

        Which begs the question of why he was trying to build the library at all?

        Methinks he perhaps Googled too much - its normally the other way around! He seems to have just blindly performed any procedure he came accross regardless of whether it was relevant, and without really knowing why he was doing it.

        I also doubt that the DevPak's project template has the libraries listed in the wrong order, and wonder if he did not use the template, or if he modified it.

        Clifford

         
        • Nobody/Anonymous

          "Which begs the question of why he was trying to build the library at all?"

          as i've said so often, a little knowledge is a dangerous thing. he may not even be able to build the library without msys or similar.

          with your thoughts and with glut listed twice i imagine he used a normal project and added libraries himself.

          snork

           
          • Nobody/Anonymous

            for what it's worth he didn't search quite enough.

            with directories setup for command line compilation compiling this project requires a "compile make mgw" and that's that. the readme file goes so far as to say "do not use msys" so it seems i was wrong in that regard.

            snork

             
            • Nobody/Anonymous

              Fascinating

              Wayne

               
              • Nobody/Anonymous

                O_o

                snork

                 

Log in to post a comment.

MongoDB Logo MongoDB