游戏开发论坛

 找回密码
 立即注册
搜索
查看: 2269|回复: 8

compiling errors in gl.h

[复制链接]

5

主题

13

帖子

19

积分

新手上路

Rank: 1

积分
19
发表于 2005-12-31 15:46:00 | 显示全部楼层 |阅读模式
#include <GL/gl.h>
#include <GL/glaux.h>

void main(void)
{
        auxInitDisplayMode(AUX_SINGLE|AUX_RGBA);
        auxInitPosition(0,0,500,500);
        auxInitWindow("simple");
        glClearColor(0.0,0.0,0.0,0.0);
        glClear(GL_COLOR_BUFFER_BIT);
        glColor3f(1.0,0.0,0.0);
        glRectf(-0.5,-0.5,0.5,0.5);
        glFlush();
        _sleep(1000);
}

the trouble is that  fatal errors occured in gl.h when compiled with vc++
errors as follow:
1. error C2144: syntax error : missing ';' before type 'void';
2. error C2501: 'WINGDIAPI' : missing storage-class or type specifiers;
3. fatal error C1004: unexpected end of file found.
who can help me ? maye this program have some wrongs.
os:winxp sp2
lib and include path have no problem.

18

主题

279

帖子

279

积分

中级会员

Rank: 3Rank: 3

积分
279
QQ
发表于 2006-1-3 09:06:00 | 显示全部楼层

Re:compiling errors in gl.h

看样子没包含<windows.h>

24

主题

256

帖子

267

积分

中级会员

Rank: 3Rank: 3

积分
267
发表于 2006-1-3 14:26:00 | 显示全部楼层

Re:compiling errors in gl.h

#include <windows.h>
#include <GL/gl.h>
#include <GL/glaux.h>

86

主题

2251

帖子

2386

积分

金牌会员

Rank: 6Rank: 6

积分
2386
QQ
发表于 2006-1-4 04:15:00 | 显示全部楼层

Re:compiling errors in gl.h

一些老的文档的例程吧
"标准"的做法是包含一个这样的头

// GLOS.H

// This is an OS specific header file

#include <windows.h>

// disable data conversion warnings

#pragma warning(disable : 4244)     // MIPS
#pragma warning(disable : 4136)     // X86
#pragma warning(disable : 4051)     // ALPHA

5

主题

13

帖子

19

积分

新手上路

Rank: 1

积分
19
 楼主| 发表于 2006-2-14 21:41:00 | 显示全部楼层

Re:compiling errors in gl.h

thank you all!
but problem hasn't been solved.
the source as below:

#include <windows.h>
#include <GL/gl.h>
#include <GL/glaux.h>
#include <glos.h>

void main(void)
{
auxInitDisplayMode(AUX_SINGLE|AUX_RGBA);
auxInitPosition(0,0,500,500);
auxInitWindow("simple");
glClearColor(0.0,0.0,0.0,0.0);
glClear(GL_COLOR_BUFFER_BIT);
glColor3f(1.0,0.0,0.0);
glRectf(-0.5,-0.5,0.5,0.5);
glFlush();
_sleep(1000);
}

compiled in vc 6.0
error occurred in main.obj,compiling was success!error is in link.
error code as below:
Linking...
main.obj : error LNK2001: unresolved external symbol __imp__glFlush@0
main.obj : error LNK2001: unresolved external symbol __imp__glRectf@16
main.obj : error LNK2001: unresolved external symbol __imp__glColor3f@12
main.obj : error LNK2001: unresolved external symbol __imp__glClear@4
main.obj : error LNK2001: unresolved external symbol __imp__glClearColor@16
main.obj : error LNK2001: unresolved external symbol _auxInitWindowA@4
main.obj : error LNK2001: unresolved external symbol _auxInitPosition@16
main.obj : error LNK2001: unresolved external symbol _auxInitDisplayMode@4
Debug/gl_temp.exe : fatal error LNK1120: 8 unresolved externals

i really don't know that compiling is right but linking is wrong!
who knows reason?help me!!!

5

主题

13

帖子

19

积分

新手上路

Rank: 1

积分
19
 楼主| 发表于 2006-2-14 22:33:00 | 显示全部楼层

Re:compiling errors in gl.h

thank godness!
i find the solution :
put the sentense as below:
#pragma comment(lib, "opengl32.lib" )
#pragma comment(lib, "glu32.lib" )
#pragma comment(lib, "GLAUX.LIB" )
in your code .all will be right!!!
问个肤浅的问题我试着找了好久,没找到)
谁能告诉怎么在vc里把这些lib库加到工程里去???就是不在程序里用以上那些语句.

5

主题

13

帖子

19

积分

新手上路

Rank: 1

积分
19
 楼主| 发表于 2006-2-14 22:55:00 | 显示全部楼层

Re:compiling errors in gl.h

in addition,i find another problem,the program above can't be compiling successfully in vc with "win32 application"
who can help me ????

24

主题

256

帖子

267

积分

中级会员

Rank: 3Rank: 3

积分
267
发表于 2006-2-16 09:19:00 | 显示全部楼层

Re: Re:compiling errors in gl.h

dj_vc: Re:compiling errors in gl.h

thank godness!
i find the solution :
put the sentense as below:
#pragma comment(lib, "opengl...


project ->settings -> Link ==>Object/library Module

5

主题

13

帖子

19

积分

新手上路

Rank: 1

积分
19
 楼主| 发表于 2006-2-16 14:24:00 | 显示全部楼层

Re:compiling errors in gl.h

谢谢!
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

作品发布|文章投稿|广告合作|关于本站|游戏开发论坛 ( 闽ICP备17032699号-3 )

GMT+8, 2026-1-23 11:49

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表