glew linking error

Started by
5 comments, last by BitMaster 11 years, 4 months ago
Hi, I am trying to compile a small test OpenGL project with GLEW and freeglut. Here is the code:


#include<cuda_runtime.h>
#include<cuda_gl_interop.h>
int g_WindowWidth;
int g_WindowHeight;
void render(void);
void createTexturedQuad(void);
int main(int argc, char** argv)
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DEPTH | GLUT_DOUBLE | GLUT_RGBA);
glutInitWindowPosition(0,0);
glutInitWindowSize(800, 600);
glutCreateWindow("Test Window");
glutDisplayFunc(render);
glutMainLoop();
//Initiallize OpenGL extensions
glewInit();
if( !glewIsSupported("GL_VERSION_4_0") )
{
return -1;
}

// viewport
glViewport(0, 0, g_WindowWidth, g_WindowHeight);
// projection
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(60.0, (GLfloat)g_WindowWidth / (GLfloat) g_WindowHeight, 0.1, 10.0);
//cudaGLSetGLDevice(gpuGetMaxGflopsDeviceId());
}
void render()
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glutSwapBuffers();
}


I get "unresolved external symbols" errors in Visual Studio 2010 where I call glewInit() and glewIsSupported(). I've added the paths to the bin/ and lib/ folders under "Library Directories" in the VC++ Directories tab. I've also added the paths to the include folders for GLEW and freeglut. In addition, I have specified that the following libraries be included: opengl32.lib, glew32.lib, freeglut.lib.

I am not sure what I could be doing to screw this up.
J.W.
Advertisement
You might need to link GLU as well, because you are using gluPerspective.
What exactly are the unresolved external symbol errors? As a general rule, you do not want to paraphrase errors, you want to copy and paste them exactly to get reliable help.
Error 2 error LNK2019: unresolved external symbol __imp__glewInit@0 referenced in function _main

Error 1 error LNK2019: unresolved external symbol __imp__glewIsSupported@4 referenced in function _main
J.W.
Try putting

#define GLEW_STATIC

before

#include <glew.h>
Tried. it doesn't help
J.W.
When you say "I have specified that the following libraries be included", how exactly did you do that? 'Including' is not the word you usually use in the context of libraries, you need to tell the linker explicitly to, well, link to them.

Also, when linking GLEW statically (when defining GLEW_STATIC), you probably want to link glew32s.lib (details will depend on how you built the library or which precompiled package you downloaded).

Also, is it possible you are using a non-Win32 configuration (e.g. x64)? You have to link libraries of the exact same architecture together. I noticed in the past that a lot of linkers will silently ignore libraries of different architectures and then you do end up with rather confusing unresolved symbol messages.

This topic is closed to new replies.

Advertisement