• Create Account

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

6 replies to this topic

### #1jdub  Members

459
Like
0Likes
Like

Posted 12 December 2012 - 12:20 AM

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);
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);
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.

### #2rocklobster  Members

415
Like
0Likes
Like

Posted 12 December 2012 - 01:53 AM

You might need to link GLU as well, because you are using gluPerspective.

### #3BitMaster  Members

8647
Like
0Likes
Like

Posted 12 December 2012 - 01:59 AM

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.

### #4jdub  Members

459
Like
0Likes
Like

Posted 12 December 2012 - 02:20 AM

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.

### #5rocklobster  Members

415
Like
0Likes
Like

Posted 12 December 2012 - 02:28 AM

Try putting

#define GLEW_STATIC

before

#include <glew.h>

### #6jdub  Members

459
Like
0Likes
Like

Posted 12 December 2012 - 03:23 AM

Tried. it doesn't help
J.W.

### #7BitMaster  Members

8647
Like
0Likes
Like

Posted 12 December 2012 - 04:07 AM

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.

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.