OpenGL实验程序,Link错误,请教原因。

xingforever 2003-07-23 09:01:23
这是学OpenGL的第一个程序:hello world,再vc6下编译通过,link出错,信息是:
Linking...
LIBCD.lib(wincrt0.obj) : error LNK2001: unresolved external symbol _WinMain@16
Debug/Hello.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.
请教原因。
程序清单:
#include <windows.h>

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

void CALLBACK draw(void);
void CALLBACK reshape(int width,int height);

void CALLBACK reshape(int width,int height){
//Set the new viewport size
glViewport(0,0,(GLint)width,(GLint)height);

//Clear the window
glClear(GL_COLOR_BUFFER_BIT);
}

void CALLBACK draw(void){

//Set the drawing color
glColor3f(1.0,1.0,1.0);

glBegin(GL_POLYGON);
glVertex2f(-0.5,-0.5);
glVertex2f(-0.5,0.5);
glVertex2f(0.5,0.5);
glVertex2f(0.5,-0.5);
glEnd();

glFlush();
}
void main(int argc,char** argv){
auxInitDisplayMode(AUX_SINGLE|AUX_RGBA);
auxInitPosition(0,0,400,400);
auxInitWindow("Hello,World!");
auxReshapeFunc(reshape);
auxMainLoop(draw);
}
...全文
120 8 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
xingforever 2003-07-24
  • 打赏
  • 举报
回复
shenhao强,一下就看出原因了。
zhouys 2003-07-24
  • 打赏
  • 举报
回复
opengl.7u7.cn
新开的,OpenGL专门的论坛!
FatGarfield 2003-07-24
  • 打赏
  • 举报
回复
1. 不要使用aux库,aux库是不被推荐使用的。
2. 使用glut库,
#include "glut.h"

在glut.h中会自动包含gl.h,
shenhao 2003-07-24
  • 打赏
  • 举报
回复
LIBCD.lib(wincrt0.obj) : error LNK2001: unresolved external symbol _WinMain@16
错误的原因是因为建的是Win32工程,主函数是WinMain()
如果建一个Win32 console,主函数才是main(), 这样就行了
allendragon 2003-07-23
  • 打赏
  • 举报
回复
给你在win2000下正确的程序:

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

void CALLBACK draw();
void CALLBACK reshape(int width,int height);

void CALLBACK reshape(int width,int height){
//Set the new viewport size
glViewport(0,0,(GLint)width,(GLint)height);

//Clear the window
glClear(GL_COLOR_BUFFER_BIT);
}

void CALLBACK draw(){

//Set the drawing color
glColor3f(1.0,1.0,1.0);

glBegin(GL_POLYGON);
glVertex2f(-0.5,-0.5);
glVertex2f(-0.5,0.5);
glVertex2f(0.5,0.5);
glVertex2f(0.5,-0.5);
glEnd();

glFlush();
}

int main(int argc, char* argv[])
{

auxInitDisplayMode(AUX_SINGLE|AUX_RGBA);
auxInitPosition(0,0,400,400);
auxInitWindow("Hello,World!");
auxReshapeFunc(reshape);
auxMainLoop(draw);

return 0;
}
xingforever 2003-07-23
  • 打赏
  • 举报
回复
系统是winxp
xingforever 2003-07-23
  • 打赏
  • 举报
回复
不行,错误无数个。我用的是vc6.0。
phoenixzz 2003-07-23
  • 打赏
  • 举报
回复
不要包含#include <windows.h>这一句

4,499

社区成员

发帖
与我相关
我的任务
社区描述
图形图像/机器视觉
社区管理员
  • 机器视觉
  • 迪菲赫尔曼
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧