GLSL installation problem

Started by
3 comments, last by brajeshlal 16 years, 11 months ago
Hi, I am new to this forum and GLSL. Learning GLSL from the www.lighthouse3d.com tutorials. I have problem in setting upo GLSL, i am using visual studio 2005, What i did was 1. Created a win32 console project template with application setting empty. Project name : myGLSL 2. Installed "glew.dll" and glut.dll in windows/system32 folder. 3. Made two folders "include" and "library" folders in Project folder "myGLSL". 4. copied glew.h,glut.h,wglew.h in "include" folder. 5. copied glew32.lib and glew32s.lib and glut32.lib in "library" folder. 6. Defined the path of the additional include and library folder to access the headers and libs. 7. Fisrt i experiment with glut code i.e. just drawing a triangle. And it is working. 8. Then i tried including some basic implementation code with glew. #include <windows.h> #include <stdio.h> #include <stdlib.h> #include <math.h> #include <glew.h> #include <glut.h> static void camSet(void); static void redraw(void); //declarations static void setShaders(void); void main(int argc, char **argv); static void redraw(void) //all drawing code goes here { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); //clears the colour and depth buffers glPushMatrix(); //saves the current matrix on the top of the matrix stack //glTranslatef(-30.0,0.0,0.0); // Move Right 3 Units glTranslatef(-20,0,-100); //translates the current matrix 0 in x, 0 in y and -100 in z glBegin(GL_TRIANGLES); //tells OpenGL that we're going to start drawing triangles glColor3f(1,0,0); //sets the current colour to red glVertex3f(-30,-30,0); //specifies the first vertex of our triangle glColor3f(0,1,0); //sets the current colour to green glVertex3f(30,-30,0); //specifies the second vertex of our triangle glColor3f(0,0,1); //sets the current colour to blue glVertex3f(-30,30,0); //specifies the third vertex of our triangle glEnd(); glPopMatrix(); //retrieves our saved matrix from the top of the matrix stack glutSwapBuffers(); //swaps the front and back buffers } static void camSet(void){ glMatrixMode(GL_PROJECTION); //changes the current matrix to the projection matrix //sets up the projection matrix for a perspective transform gluPerspective(45, //view angle 1.0, //aspect ratio 10.0, //near clip 200.0); //far clip glMatrixMode(GL_MODELVIEW); } static void setShaders(void){ } void main(int argc, char **argv) { glutInit(&argc,argv); //initializes the GLUT framework glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH); //sets up the display mode glutCreateWindow("My first GLUT Trainagle program"); //creates a window glutDisplayFunc(redraw); //specifies our redraw function camSet(); glewInit(); if (glewIsSupported("GL_VERSION_2_0")) printf("Ready for OpenGL 2.0\n"); else { printf("OpenGL 2.0 not supported\n"); exit(1); } setShaders(); glutMainLoop(); //the main loop of the GLUT framework } error comes: 1>------ Build started: Project: myGLSL, Configuration: Debug Win32 ------ 1>Compiling... 1>firstGLSL.cpp 1>Linking... 1>firstGLSL.obj : error LNK2019: unresolved external symbol __imp__glewIsSupported referenced in function _main 1>firstGLSL.obj : error LNK2019: unresolved external symbol __imp__glewInit referenced in function _main 1>C:\med10\myGLSL\Debug\myGLSL.exe : fatal error LNK1120: 2 unresolved externals 1>Build log was saved at "file://c:\med10\myGLSL\myGLSL\Debug\BuildLog.htm" 1>myGLSL - 3 error(s), 0 warning(s) ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Advertisement
That error normally means that you have not told the compiler to link with glew32.lib, or that the compiler could not find that library.

Did you also put glew32.lib in Project Options->Linker->Additional Dependencies ? And that the path you put in at step 6 is either an absolute path (C:\myGLSL\library) or relative to the solution file?
What I did was

Under Project Options->Linker->Additional Libarary directories

I have metioned
C:\med10\myGLSL\library..... an absolute path for libs


and under Project Options->c/c++->Additional Include directories.
C:\med10\myGLSL\include;
C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\Include\gl


As a Folder structure
I have folder called c:->med10->myGLSL

Inside "myGLSL" folder i have 5 items.

1. Again a folder called "myGLSL". Items i have in this folder are

1.a. firstGLSL.cpp
1.b. myGLSL.vcproj
1.c. myGLSL.vcproj.BRAJESH.Brajesh Behari Lal.user
1.d. "Debug" folder

2. "Include" folder // made by me and contains three files.
glew.h,glut.h and wglew.h
3."Library" folder. Which has also three files
glew32.lib, glew32s.lib and glut.lib
4. myGLSL.ncb
5. myGLSL.sln
6. "debug" folder . Contains file myGLSL.pdb

code which i pasted was wriiten into the file "firstGLSL.cpp"

It's not enough to just have the glew.lib in the library path you must also tell visual studio to link it in as well.

Either go into the project properties->linker->input and add "glew32.lib" to the list of libs or alternatively have a line like the following within your firstGLSL.cpp:

#pragma comment( lib, "glew32.lib" )

I've just tried the exact same piece of code without problem so it looks like your compiler is simply failing to find the glew32.lib file or you're forgetting to link to it correctly.

Andy

"Ars longa, vita brevis, occasio praeceps, experimentum periculosum, iudicium difficile"

"Life is short, [the] craft long, opportunity fleeting, experiment treacherous, judgement difficult."

Thnaks andy, I am able to compile now.......
when i added
#pragma comment( lib, "glew32.lib" ).....

This topic is closed to new replies.

Advertisement