Question

I coded a simple SDL/OpenGL program which displays a simple triangle in rotation. I first compiled and executed my application as a Win32 application and it works perfectly. But with a x64 configuration (using the configuration manager of Visual) the compilation fails. All the OpenGL methods has not been found. Here's my errors :

1>main.obj : error LNK2019: symbole externe non résolu __imp_glBegin référencé dans la fonction main
1>main.obj : error LNK2019: symbole externe non résolu __imp_glClear référencé dans la fonction main
1>main.obj : error LNK2019: symbole externe non résolu __imp_glClearColor référencé dans la fonction main
1>main.obj : error LNK2019: symbole externe non résolu __imp_glColor3ub référencé dans la fonction main
1>main.obj : error LNK2019: symbole externe non résolu __imp_glEnable référencé dans la fonction main
1>main.obj : error LNK2019: symbole externe non résolu __imp_glEnd référencé dans la fonction main
1>main.obj : error LNK2019: symbole externe non résolu __imp_glLoadIdentity référencé dans la fonction main
1>main.obj : error LNK2019: symbole externe non résolu __imp_glPopMatrix référencé dans la fonction main
1>main.obj : error LNK2019: symbole externe non résolu __imp_glPushMatrix référencé dans la fonction main
1>main.obj : error LNK2019: symbole externe non résolu __imp_glRotatef référencé dans la fonction main
1>main.obj : error LNK2019: symbole externe non résolu __imp_glScalef référencé dans la fonction main
1>main.obj : error LNK2019: symbole externe non résolu __imp_glTranslatef référencé dans la fonction main
1>main.obj : error LNK2019: symbole externe non résolu __imp_glVertex3f référencé dans la fonction main
1>main.obj : error LNK2019: symbole externe non résolu __imp_glViewport référencé dans la fonction main
1>C:\Users\VOLODIA\Desktop\SDLOpenGL64Test\x64\Debug\SDLOpenGL64Test.exe : fatal error LNK1120: 14 externes non résolus

And my simple c++ application code :

#include <iostream>
#include <SDL/SDL.h>
#include <GL/glew.h>
#include <GL/glu.h>

#define WIDTH 500
#define HEIGHT 500

static float angle = 0.0f;

static void eventListener(SDL_Event *pEvent, bool *pContinue)
{
    while (SDL_PollEvent(pEvent))
    {
        switch(pEvent->type)
        {
            case SDL_QUIT:
                *pContinue = false;
                break;
            case SDL_KEYDOWN:
                switch (pEvent->key.keysym.sym)
                {
                    case SDLK_ESCAPE:
                        *pContinue = false;
                        break;
                }
            break;
        }
    }
}

#undef main

int main(void)
{
    SDL_Event myEvent;
    bool isAlive = true;

    SDL_Init(SDL_INIT_VIDEO);
    SDL_WM_SetCaption("Simple SDL window", NULL);
    SDL_SetVideoMode(WIDTH, HEIGHT, 32, SDL_OPENGL);

    if (glewInit() == -1) {
        std::cout << "glewInit failed." << std::endl;
        getchar();
        return (EXIT_FAILURE);
    }

    while (isAlive == true)
    {
        eventListener(&myEvent, &isAlive);
        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
        glClearColor(0.0f, 0.0f, 0.0f, 1.0f);

        glViewport(0, 0, WIDTH, HEIGHT);
        glEnable(GL_PROJECTION);
        glLoadIdentity();
        gluPerspective(45.0f, (float)WIDTH/(float)HEIGHT, 0.1f, 100.0f);
        gluLookAt(0.0f, 0.0f, 5.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f);

        glEnable(GL_MODELVIEW);

        glPushMatrix();

        glTranslatef(0.0f, 0.0f, 0.0f);
        glRotatef(angle, 1.0f, 1.0f, 1.0f);
        glScalef(1.0f, 1.0f, 1.0f);

        glBegin(GL_TRIANGLES);
        glColor3ub(255, 0, 0);
        glVertex3f(0.0f, 0.75f, 0.0f);
        glColor3ub(0, 255, 0);
        glVertex3f(-0.75f, 0.0f, 0.0f);
        glColor3ub(0, 0, 255);
        glVertex3f(0.75f, 0.0f, 0.0f);
        glEnd();

        angle+=1.0f;
        glPopMatrix();

        SDL_GL_SwapBuffers();
    }
    SDL_Quit();
    return (0);
}

I download several versions of the glew package in the following URL :

http://glew.sourceforge.net/

I linked my application with glew32.lib (I wonder why they have called your lib by glew32.lib and not glew64.lib it's pretty strange...) but I always have the same messages. So I've performed other research to find something like glew64.lib and I downloaded this time a library file called 'glew64.lib' on the following URL:

https://code.google.com/p/wowmodelviewer/source/browse/trunk/src/lib/Windows/64bit/glew64.lib?spec=svn492&r=492

I linked it with my application but it's still the same thing ! Does anyone already have encountered the same problem ? I'm lost. Thanks a lot in advance for your help.

Was it helpful?

Solution

GLEW convers everything that's beyond OpenGL-1.1, but nothing OpenGL-1.1 provides. The symbols reported are part of OpenGL-1.1 and you must add opengl32.lib to the list of linked libraries, in addition to GLEW:

(I wonder why they have called your lib by glew32.lib and not glew64.lib it's pretty strange...

It's not strage, it's consistent. Even on 64 bit Windows the OpenGL interface DLL is called opengl32.dll

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top