Jump to content

Welcome to Geeks to Go - Register now for FREE

Geeks To Go is a helpful hub, where thousands of volunteer geeks quickly serve friendly answers and support. Check out the forums and get free advice from the experts. Register now to gain access to all of our features, it's FREE and only takes one minute. Once registered and logged in, you will be able to create topics, post replies to existing threads, give reputation to your fellow members, get your own private messenger, post status updates, manage your profile and so much more.

Create Account How it Works
Photo

OpenGL Compile errors Visual Studio 6


  • Please log in to reply

#1
dubucam

dubucam

    New Member

  • Member
  • Pip
  • 2 posts
Hi,

I am having compile errors when I included the OpenGL header files to a simple program. I am using Visual Studios 6.0 on Windows XP.

// Testing OpenGL includes

#include <iostream>

//#include <GL/gl.h>
//#include <GL/glu.h>

#include <gl.h>
#include <glu.h>

using namespace std;

int main()
{

cout << "Hello world" << endl;

return 0;

}


Then I get this compile error:

c:\program files\microsoft visual studio\vc98\include\gl\gl.h(1135) : error C2144: syntax error : missing ';' before type 'void'
c:\program files\microsoft visual studio\vc98\include\gl\gl.h(1135) : error C2501: 'WINGDIAPI' : missing storage-class or type specifiers
c:\program files\microsoft visual studio\vc98\include\gl\gl.h(1135) : fatal error C1004: unexpected end of file found


I am not sure what I need to do correct this. I thought maybe the MS Visual Studio files were bad, so I downloaded new files but I am still getting the same compile error?

Any assistance would be appreciated - thanks in advance.

Edited by dubucam, 20 May 2005 - 12:49 PM.

  • 0

Advertisements


#2
stu_design

stu_design

    Member

  • Member
  • PipPipPip
  • 217 posts
this should go in the programming section but hey
  • 0

#3
rockwall

rockwall

    New Member

  • Member
  • Pip
  • 5 posts
i havn't had much experience with c++ but i had the same problem and this fixed it:

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

(u might also need to download opengl32.lib.)

if this works, plz check my post on 'opengl game programming'
  • 0

#4
equinox

equinox

    New Member

  • Member
  • Pip
  • 1 posts
Hello dubucam, i have a simular problem with attempting to compile and run a tutorial .c file.

On compile time is comes up with the following:
Compiling...
selest.cpp
c:\program files\microsoft visual studio\vc98\include\gl\gl.h(1152) : error C2144: syntax error : missing ';' before type 'void'
c:\program files\microsoft visual studio\vc98\include\gl\gl.h(1152) : error C2501: 'WINGDIAPI' : missing storage-class or type specifiers
c:\program files\microsoft visual studio\vc98\include\gl\gl.h(1152) : fatal error C1004: unexpected end of file found
Error executing cl.exe.

selest.obj - 3 error(s), 0 warning(s)

Have you found a solution yet to compile gl.h ??
  • 0

#5
BuRnEr

BuRnEr

    Member

  • Member
  • PipPip
  • 48 posts
Here is your solution:

Requirements: Visual Studio .net 2003 or 2002 or 2005
Actually so many people has this problem and I saw that I have to add my comment here

So first if you are using win 2000 pro , or server or xp home or pro
First you have to download glut for windows and you can get it from
(note!!!! get first one, named "glut-3.7.6-bin.zip (117 KB)"
http://www.xmission....~nate/glut.html

Now just uncompressed it in some location where you can access it.
And open the this folder and take files from it put them to these locations: just copy and past…

glut32.dll -> C:\WINDOWS\system\

glut32.lib -> C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Lib

glut32.h -> C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\gl

open vs.net and create new project->choose win32 console application -> and name it whatever you like->ok ->choose empty project -> and finish

and go project ->properties -> window pop up
configuration section: choose the “All Configurations”

now in same window left of window under the Linker->you ll find the “input” section and click on it
and clic the additional Dependencies copy and paste this : opengl32.lib glu32.lib glut32.lib

and choose the Command Line left of window under Linker : copy and paste this : /SUBSYSTEM:WINDOWS/ENTRY: mainCRTStartup to Additional Options section.

So now your development environment is ready:

In your case example:

#include <windows.h>
#include <iostream>
#include <GL/gl.h> //actually you don’t need to use this
#include <GL/glu.h> //and this too
using namespace std;


int main()
{

cout << "Hello world" << endl;

return 0;

}

take care:
BuRnEr
  • 0

#6
mac96005

mac96005

    New Member

  • Member
  • Pip
  • 1 posts
Thank you for that excellent explanation. I tried your reccomendation but I had a problem.

What type of file do you create to display hello world. I created a Generic C++ Class, but i get the following error:

LINK : fatal error LNK1117: syntax error in option 'SUBSYSTEM:WINDOWS/ENTRY:'

Also, if i just add:

mainCRTStartup

to the Command Line Option under Linker instead of the full:

SUBSYSTEM:WINDOWS/ENTRY: mainCRTStartup

Then I get the following error:

LINK : fatal error LNK1104: cannot open file 'mainCRTStartup.obj'
  • 0

#7
pumpkindyy

pumpkindyy

    New Member

  • Member
  • Pip
  • 2 posts
BuRnEr

Could you tell me why must add #include <windows.h> at the beginning of program?
Thanks

Good Luck!
  • 0

#8
BuRnEr

BuRnEr

    Member

  • Member
  • PipPip
  • 48 posts
mac96005:

I dont know exactly how did you do it but if you followed the steps correctly you shouldnt get an error.....And I did not see your code too
so i am not sure but read this:
firs of all actually you dont even need to create class for this little program.
..
if you did everything right than...that means check everything again.

so what type of file you should create:
"open vs.net and create new project->choose win32 console application -> and name it whatever you like->ok ->choose empty project -> and finish "


looks like "after" creating project, you did not configure properties of project....
like:
"and go project ->properties -> window pop up
configuration section: choose the “All Configurations”
now in same window left of window under the Linker->you ll find the “input” section and click on it
and clic the additional Dependencies copy and paste this : opengl32.lib glu32.lib glut32.lib"

NOW:
on solution explorer, right click on source Files under project -> add new item -> select C++ file (cpp) option and enter name click open. And just copy the codes paste it in your cpp file and build(run) it. it should work..

if you want to create your own class or methods better to create also header file under header files, and never forget that you can not use methods before declare it in c++ it means that if you creating methods after main function you get errors..
example
main(){
udfunc();
}
udfunc(){
//some code
}
this is error
---------------------
undfunc(){
//somecode here
}
main(){
undfunc()
}
works fine
-----
there is a other ways to do that but this is most common way


pumpkindyy
your questions answer:why have to use <windows.h>
Bcause you are making program based entirely on windows environgment and programming done within the Windows environment, So you have to access Windows machine and compiler for compellation and so on...
i guess it is clear by now

Take care
BuRnEr
  • 0

#9
pumpkindyy

pumpkindyy

    New Member

  • Member
  • Pip
  • 2 posts
To BuRnEr :

Thanks a lot, I got it!

Good Luck!
pumpkindyy
  • 0






Similar Topics

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

As Featured On:

Microsoft Yahoo BBC MSN PC Magazine Washington Post HP