Linker-Error mit GLFW



  • Hallo!
    ich möcht anfangen mit OpenGL-programmierung.. dafür hab ich mir die GLFW-lib runtergeladen

    http://glfw.sourceforge.net/

    Ich verwende VC++
    die binary-files
    dann hab ich die lib-files, das dll-file und das header-file in meinen projekt-ordner verschoben.

    beim Linker hab ich unter Eingabe
    "glfw.lib opengl32.lib glu32.lib" eingestellt (ohne die ")

    programm:

    #define GLFW_DLL
    
    #include <stdlib.h>    // For malloc() etc.
    #include <stdio.h>     // For printf(), fopen() etc.
    #include <math.h>      // For sin(), cos() etc.
    #include <GL/glfw.h>   // For GLFW, OpenGL and GLU
    
    //----------------------------------------------------------------------
    // Draw() - Main OpenGL drawing function that is called each frame
    //----------------------------------------------------------------------
    
    void Draw( void )
    {
        int    width, height;  // Window dimensions
        double t;              // Time (in seconds)
    
        // Get current time
        t = glfwGetTime();
    
        // Get window size
        glfwGetWindowSize( &width, &height );
    
        // Make sure that height is non-zero to avoid division by zero
        height = height < 1 ? 1 : height;
    
        // Set viewport
        glViewport( 0, 0, width, height );
    
        // Clear color and depht buffers
        glClearColor( 0.0f, 0.0f, 0.0f, 0.0f );
        glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
    
        // Set up projection matrix
        glMatrixMode( GL_PROJECTION );    // Select projection matrix
        glLoadIdentity();                 // Start with an identity matrix
        gluPerspective(                   // Set perspective view
            65.0,                         // Field of view = 65 degrees
            (double)width/(double)height, // Window aspect (assumes square pixels)
            1.0,                          // Near Z clipping plane
            100.0                         // Far Z clippling plane
        );
    
        // Set up modelview matrix
        glMatrixMode( GL_MODELVIEW );     // Select modelview matrix
        glLoadIdentity();                 // Start with an identity matrix
        gluLookAt(                        // Set camera position and orientation
            0.0, 0.0, 10.0,               // Camera position (x,y,z)
            0.0, 0.0, 0.0,                // View point (x,y,z)
            0.0, 1.0, 0.0                 // Up-vector (x,y,z)
        );
    
        // Here is where actual OpenGL rendering calls would begin...
    }
    
    //----------------------------------------------------------------------
    // main() - Program entry point
    //----------------------------------------------------------------------
    
    int main( int argc, char **argv )
    {
        int    ok;             // Flag telling if the window was opened
        int    running;        // Flag telling if the program is running
    
        // Initialize GLFW
        glfwInit();
    
        // Open window
        ok = glfwOpenWindow(
            640, 480,          // Width and height of window
            8, 8, 8,           // Number of red, green, and blue bits for color buffer
            8,                 // Number of bits for alpha buffer
            24,                // Number of bits for depth buffer (Z-buffer)
            0,                 // Number of bits for stencil buffer
            GLFW_WINDOW        // We want a desktop window (could be GLFW_FULLSCREEN)
        );
    
        // If we could not open a window, exit now
        if( !ok )
        {
            glfwTerminate();
            return 0;
        }
    
        // Set window title
        glfwSetWindowTitle( "My OpenGL program" );
    
        // Enable sticky keys
        glfwEnable( GLFW_STICKY_KEYS );
    
        // Main rendering loop
        do
        {
            // Call our rendering function
            Draw();
    
            // Swap front and back buffers (we use a double buffered display)
            glfwSwapBuffers();
    
            // Check if the escape key was pressed, or if the window was closed
            running = !glfwGetKey( GLFW_KEY_ESC ) &&
                      glfwGetWindowParam( GLFW_OPENED );
        }
        while( running );
    
        // Terminate GLFW
        glfwTerminate();
    
        // Exit program
        return 0;
    }
    

    (hab ich selbst nur kopiert)

    problem.. ich bekomm jede menge Linker-error, find aber den fehler einfach nicht..

    error LNK2019: Verweis auf nicht aufgelöstes externes Symbol "__imp__glfwGetWindowSize@8" in Funktion ""void __cdecl Draw(void)" (?Draw@@YAXXZ)".
    

    ich hoff dass mir wer helfen kann..

    mfg Spong3bob



  • Hast du es schon mit dem VC8 Projekttemplate versucht?
    (Gibt es im Source Archive von GLFW.)

    Was hast du für eine VC Version?

    Method 1 - From the command prompt, type:

    cl lesson01.c glfw.lib opengl32.lib glu32.lib user32.lib

    Funktioniert das? Wenn ja, musst wahrscheinlich die user32.lib auch noch beim Linker mit einstellen.



  • hab ich auch schon probiert mit user32.lib
    ich hab Visual C++ 2008 Express Edition

    Werd mir das ganze morgen nochmal anschaun..



  • so.. ich hab das heute wieder in angriff genommen...

    ich hab den ersten download genommen, die readme.html geöffnet und alles nach der anleitung gemacht.. es werden auch die .lib-files, etc erstellt, aber mit den files kommt noch immer die selbe fehlermeldung..



  • Mein erster Beitrag hier im Forum. 🙂

    Versuchs mal damit, das "#define GLFW_DLL" zu löschen. Soweit ich sehen kann, linkst du ja statisch und nicht mit einer DLL. 😉

    Bei mir hats to mit MinGW funktioniert.
    Ohne DLL (also ohne define): "gcc -o file.exe file.cpp -lglfw -lopengl32 -lglu32"
    Mit DLL (also auch mit define): "gcc -o file.exe file.cpp -lglfwdll -lopengl32 -lglu32"


Anmelden zum Antworten