errors with glut and glew

well im trying to do some practice code and im having a little bit of difficulty. my code is perfect (its from the interwebs approved by my prof) but my headers are kinda screwing me up.

i get this error message when i #include glut and glew "1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\gl\glew.h(84): fatal error C1189: #error : gl.h included before glew.h"

but when i include gl.h, i get 100 some odd error messages


if anyone has any ideas as to how i can fix this, it would be greatly appreciated.

visual studio 2010


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#include <Gl\glut.h> 
#include <GL\glew.h> 



void render(void) 

{
	glClear (GL_COLOR_BUFFER_BIT);
	glColor3f (1.0,1.0,1.0); 

	//Square Number 1
	glBegin (GL_POLYGON);
		glVertex3f (20.0, 20.0, 0.0);
		glVertex3f (80.0, 20.0, 0.0); 
		glVertex3f (80.0, 80.0, 0.0);
		glVertex3f (20.0, 80.0, 0.0);
	glEnd ();
	glFlush ();

}

	int main (int argc, char **argv)

	{
		glutInit (&argc, argv); 
		glutInitDisplayMode ( GLUT_DEPTH| GLUT_SINGLE | GLUT_RGBA);
		glutInitWindowPosition (100, 100);
		glutInitWindowSize (500, 500);
		glutCreateWindow ("Sample");

		glClearColor (0.0, 0.0, 0.0, 0.0);
		glOrtho (0.0, 100.0, 0.0, 100.0, -1.0, 1.0);

		glutDisplayFunc(render);
		glutMainLoop ();
		return 0;
	}
Did you try including glew before glut?
I think glut includes gl.h so you don't have to include it.

1
2
#include <GL\glew.h> 
#include <Gl\glut.h>  

i just tried that and i got 7 errors instead of 1 haha

1>c:\Users\User\documents\visual studio 2010\Projects\exercise1\exercise1\exercise1.vcxproj : error MSB4014: The build stopped unexpectedly because of an internal failure.
1>c:\Users\User\documents\visual studio 2010\Projects\exercise1\exercise1\exercise1.vcxproj : error MSB4014: Microsoft.Build.Exceptions.BuildAbortedException: Build was canceled. MSBuild.exe could not be launched as a child node as it could not be found at the location "C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe". If necessary, specify the correct location in the BuildParameters, or with the MSBUILD_EXE_PATH environment variable.
1>c:\Users\User\documents\visual studio 2010\Projects\exercise1\exercise1\exercise1.vcxproj : error MSB4014: at Microsoft.Build.BackEnd.NodeManager.AttemptCreateNode(INodeProvider nodeProvider, NodeConfiguration nodeConfiguration)
1>c:\Users\User\documents\visual studio 2010\Projects\exercise1\exercise1\exercise1.vcxproj : error MSB4014: at Microsoft.Build.BackEnd.NodeManager.CreateNode(NodeConfiguration configuration, NodeAffinity nodeAffinity)
1>c:\Users\User\documents\visual studio 2010\Projects\exercise1\exercise1\exercise1.vcxproj : error MSB4014: at Microsoft.Build.Execution.BuildManager.PerformSchedulingActions(IEnumerable`1 responses)
1>c:\Users\User\documents\visual studio 2010\Projects\exercise1\exercise1\exercise1.vcxproj : error MSB4014: at Microsoft.Build.Execution.BuildManager.HandleNewRequest(Int32 node, BuildRequestBlocker blocker)
1>c:\Users\User\documents\visual studio 2010\Projects\exercise1\exercise1\exercise1.vcxproj : error MSB4014: at Microsoft.Build.Execution.BuildManager.IssueRequestToScheduler(BuildSubmission submission, Boolean allowMainThreadBuild, BuildRequestBlocker blocker)
anything from anybody?
The first error you got:
#error : gl.h included before glew.h"

was a pre-processor error intentionally built into glew.h. Therefore the correct action was to include glew.h before glut.h.

Because the preprocessor is done before compilation, the compilation never even started which means you never had a chance to get any other errors.

Believe it or not, you are actually now closer to your solution than before (despite more errors).

The errors that you got were actually internal errors in the Visual Studio compiler. I don't know how or what could cause those. I'd suggest cleaning your solution, then rebuilding the solution twice. If the errors still happen, maybe reboot. If they still happen, then see if you can re-install and re-link the glut/glew libraries.

Edit: Actually, what happens if you omit <GL/glew.h> all togeather? (comment it out)
Last edited on
if i omit <GL/glew.h> all together i get these errors

1>------ Build started: Project: exercise1, Configuration: Debug Win32 ------
1> Exercise1.cpp
1>Exercise1.obj : error LNK2019: unresolved external symbol __imp__glutMainLoop@0 referenced in function _main
1>Exercise1.obj : error LNK2019: unresolved external symbol __imp__glutDisplayFunc@4 referenced in function _main
1>Exercise1.obj : error LNK2019: unresolved external symbol __imp__glutInitWindowSize@8 referenced in function _main
1>Exercise1.obj : error LNK2019: unresolved external symbol __imp__glutInitWindowPosition@8 referenced in function _main
1>Exercise1.obj : error LNK2019: unresolved external symbol __imp__glutInitDisplayMode@4 referenced in function _main
1>Exercise1.obj : error LNK2019: unresolved external symbol __imp____glutInitWithExit@12 referenced in function _glutInit_ATEXIT_HACK@8
1>Exercise1.obj : error LNK2019: unresolved external symbol __imp____glutCreateWindowWithExit@8 referenced in function _glutCreateWindow_ATEXIT_HACK@4
1>C:\Users\User\documents\visual studio 2010\Projects\exercise1\Debug\exercise1.exe : fatal error LNK1120: 7 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

if i include <GL/glew.h> after <GL/glut.h> i only get this error

1>------ Build started: Project: exercise1, Configuration: Debug Win32 ------
1> Exercise1.cpp
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\gl\glew.h(84): fatal error C1189: #error : gl.h included before glew.h

i did try a reboot before i tried to build and im about to try and delete all of the glut and glew libraries and start all over......but this is such a pain. opengl is such an awesome feature (i was an engineering major before i switched to computer science). but its such a pain to setup
Topic archived. No new replies allowed.