最近在学图像处理
用的是VC6.0
下载了一个例子 这样做还是连接错误1、将下载的压缩包解开,将得到5个文件
2、以我的安装目录为例:
(1)“d:\Program Files\Microsoft Visual Studio\VC98\include\GL文件夹”。把解压得到的glut.h放到这个GL文件夹里。没有GL文件夹可以自己建一个,一般都有的。
(2)“d:\Program Files\Microsoft Visual Studio\VC98\lib文件夹”。把解压得到的glut.lib和glut32.lib放到静态函数库所在文件夹,即lib文件夹。
(3)把解压得到的glut.dll和glut32.dll放到操作系统目录下面的system32文件夹内。(典型的位置为:C:\Windows\System32)这是非常重要的动态链接库设置!
第三步,创建工程,其步骤如下:
(1)创建一个Win32 Console Application。(以我创建的为例,工程名为simpleGL)
(2)链接OpenGL libraries:在Visual C++中先单击Project,再单击Settings,再找到Link单击,最后在Object/library modules 的最前面加上opengl32.lib Glut32.lib Glaux.lib glu32.lib 。
(3)单击Project Settings中的C/C++标签,将Preprocessor definitions 中的_CONSOLE改为__WINDOWS。最后单击OK。
(4)每新建一个工程都要重复第三步中的(1)-(3)。
现在,准备工作基本上完成了,可不要轻视这一步,如果你没有设置好在编译及运行过程中总会出错的。 还要怎么设置么 ??
用的是VC6.0
下载了一个例子 这样做还是连接错误1、将下载的压缩包解开,将得到5个文件
2、以我的安装目录为例:
(1)“d:\Program Files\Microsoft Visual Studio\VC98\include\GL文件夹”。把解压得到的glut.h放到这个GL文件夹里。没有GL文件夹可以自己建一个,一般都有的。
(2)“d:\Program Files\Microsoft Visual Studio\VC98\lib文件夹”。把解压得到的glut.lib和glut32.lib放到静态函数库所在文件夹,即lib文件夹。
(3)把解压得到的glut.dll和glut32.dll放到操作系统目录下面的system32文件夹内。(典型的位置为:C:\Windows\System32)这是非常重要的动态链接库设置!
第三步,创建工程,其步骤如下:
(1)创建一个Win32 Console Application。(以我创建的为例,工程名为simpleGL)
(2)链接OpenGL libraries:在Visual C++中先单击Project,再单击Settings,再找到Link单击,最后在Object/library modules 的最前面加上opengl32.lib Glut32.lib Glaux.lib glu32.lib 。
(3)单击Project Settings中的C/C++标签,将Preprocessor definitions 中的_CONSOLE改为__WINDOWS。最后单击OK。
(4)每新建一个工程都要重复第三步中的(1)-(3)。
现在,准备工作基本上完成了,可不要轻视这一步,如果你没有设置好在编译及运行过程中总会出错的。 还要怎么设置么 ??
解决方案 »
- MFC中使用了libcurl库,选择“静态库中使用 MFC”编译出错
- 如何设置WEB页面为桌面墙纸.100分在线等.
- 一个关于调用exe问题,大侠进......
- 关于半透明显示的问题?
- 经理让我找一些面试的题目,可是我也很讨厌笔试,特别是那种什么专找墙角的题目了,所以需要各位兄弟帮忙一下
- 关于在ondraw()中会闪的问题
- 哪位大侠讲一讲在VC中用SOCKET下载一个文件的思路,MFC,SDK都可,分数足够,越深越好
- 请问,如何使用热键来激活一个程序?
- 请问访问vsd文件要用什么软件?
- 关于PlaySound 函数的问题
- 不借助MFC/ATL,在一个win32 dll的工程里面去实现一个Com服务组件,需要做哪些事情?
- 怀疑执行了剪贴板代码后,程序崩溃,请教了
#include <GL/glut.h>void myDisplay(void)
{
glClear(GL_COLOR_BUFFER_BIT);
glRectf(-0.5f, -0.5f, 0.5f, 0.5f);
glFlush();
}int main(int argc, char *argv[])
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_RGB | GLUT_SINGLE);
glutInitWindowPosition(100, 100);
glutInitWindowSize(400, 400);
glutCreateWindow("第一个OpenGL程序");
glutDisplayFunc(&myDisplay);
glutMainLoop();
return 0;
}
Linking...
a.obj : error LNK2001: unresolved external symbol ___glutInitWithExit@12
a.obj : error LNK2001: unresolved external symbol ___glutCreateWindowWithExit@8
Debug/simple.exe : fatal error LNK1120: 2 unresolved externals
执行 link.exe 时出错.simple.exe - 1 error(s), 0 warning(s)
帮忙看一下为什么出问题啊
#include <GL/gl.h>
#include <GL/glut.h>
#include <GL/glaux.h>
d:\vc98\include\gl\gl.h(1152) : error C2085: 'APIENTRY' : not in formal parameter list
d:\vc98\include\gl\gl.h(1152) : error C2146: syntax error : missing ',' before identifier 'glAccum'
d:\vc98\include\gl\gl.h(1152) : error C2143: syntax error : missing ';' before '('
d:\vc98\include\gl\gl.h(1152) : error C2059: syntax error : ')'
d:\vc98\include\gl\gl.h(1153) : error C2054: expected '(' to follow 'WINGDIAPI'
d:\vc98\include\gl\gl.h(1153) : error C2085: 'APIENTRY' : not in formal parameter list
d:\vc98\include\gl\gl.h(1153) : error C2146: syntax error : missing ',' before identifier 'glAlphaFunc'
d:\vc98\include\gl\gl.h(1153) : error C2143: syntax error : missing ';' before '('
d:\vc98\include\gl\gl.h(1153) : error C2059: syntax error : ')'
d:\vc98\include\gl\gl.h(1154) : error C2054: expected '(' to follow 'WINGDIAPI'
d:\vc98\include\gl\gl.h(1154) : error C2085: 'APIENTRY' : not in formal parameter list
d:\vc98\include\gl\gl.h(1154) : error C2146: syntax error : missing ',' before identifier 'glAreTexturesResident'
d:\vc98\include\gl\gl.h(1154) : error C2143: syntax error : missing ';' before '('
d:\vc98\include\gl\gl.h(1154) : error C2059: syntax error : ')'
d:\vc98\include\gl\gl.h(1155) : error C2054: expected '(' to follow 'WINGDIAPI'
d:\vc98\include\gl\gl.h(1155) : error C2085: 'APIENTRY' : not in formal parameter list
d:\vc98\include\gl\gl.h(1155) : error C2146: syntax error : missing ',' before identifier 'glArrayElement'
d:\vc98\include\gl\gl.h(1155) : error C2143: syntax error : missing ';' before '('
d:\vc98\include\gl\gl.h(1155) : error C2059: syntax error : ')'
d:\vc98\include\gl\gl.h(1156) : error C2054: expected '(' to follow 'WINGDIAPI'
d:\vc98\include\gl\gl.h(1156) : error C2085: 'APIENTRY' : not in formal parameter list
d:\vc98\include\gl\gl.h(1156) : error C2146: syntax error : missing ',' before identifier 'glBegin'
d:\vc98\include\gl\gl.h(1156) : error C2143: syntax error : missing ';' before '('
d:\vc98\include\gl\gl.h(1156) : error C2059: syntax error : ')'
d:\vc98\include\gl\gl.h(1157) : error C2054: expected '(' to follow 'WINGDIAPI'
d:\vc98\include\gl\gl.h(1157) : error C2085: 'APIENTRY' : not in formal parameter list
d:\vc98\include\gl\gl.h(1157) : error C2146: syntax error : missing ',' before identifier 'glBindTexture'
d:\vc98\include\gl\gl.h(1157) : error C2143: syntax error : missing ';' before '('
d:\vc98\include\gl\gl.h(1157) : error C2059: syntax error : ')'
d:\vc98\include\gl\gl.h(1158) : error C2054: expected '(' to follow 'WINGDIAPI'
d:\vc98\include\gl\gl.h(1158) : error C2085: 'APIENTRY' : not in formal parameter list
d:\vc98\include\gl\gl.h(1158) : error C2146: syntax error : missing ',' before identifier 'glBitmap'
d:\vc98\include\gl\gl.h(1158) : error C2143: syntax error : missing ';' before '('
d:\vc98\include\gl\gl.h(1158) : error C2059: syntax error : ')'
d:\vc98\include\gl\gl.h(1159) : error C2054: expected '(' to follow 'WINGDIAPI'
d:\vc98\include\gl\gl.h(1159) : error C2085: 'APIENTRY' : not in formal parameter list
d:\vc98\include\gl\gl.h(1159) : error C2146: syntax error : missing ',' before identifier 'glBlendFunc'
d:\vc98\include\gl\gl.h(1159) : error C2143: syntax error : missing ';' before '('
d:\vc98\include\gl\gl.h(1159) : error C2059: syntax error : ')'
d:\vc98\include\gl\gl.h(1160) : error C2054: expected '(' to follow 'WINGDIAPI'
d:\vc98\include\gl\gl.h(1160) : error C2085: 'APIENTRY' : not in formal parameter list
d:\vc98\include\gl\gl.h(1160) : error C2146: syntax error : missing ',' before identifier 'glCallList'
d:\vc98\include\gl\gl.h(1160) : error C2143: syntax error : missing ';' before '('
d:\vc98\include\gl\gl.h(1160) : error C2059: syntax error : ')'
d:\vc98\include\gl\gl.h(1161) : error C2054: expected '(' to follow 'WINGDIAPI'
d:\vc98\include\gl\gl.h(1161) : error C2085: 'APIENTRY' : not in formal parameter list
d:\vc98\include\gl\gl.h(1161) : error C2146: syntax error : missing ',' before identifier 'glCallLists'
d:\vc98\include\gl\gl.h(1161) : error C2143: syntax error : missing ';' before '('
d:\vc98\include\gl\gl.h(1161) : error C2059: syntax error : ')'
d:\vc98\include\gl\gl.h(1162) : error C2054: expected '(' to follow 'WINGDIAPI'
d:\vc98\include\gl\gl.h(1162) : error C2085: 'APIENTRY' : not in formal parameter list
d:\vc98\include\gl\gl.h(1162) : error C2146: syntax error : missing ',' before identifier 'glClear'
d:\vc98\include\gl\gl.h(1162) : error C2143: syntax error : missing ';' before '('
d:\vc98\include\gl\gl.h(1162) : error C2059: syntax error : ')'
d:\vc98\include\gl\gl.h(1163) : error C2054: expected '(' to follow 'WINGDIAPI'
d:\vc98\include\gl\gl.h(1163) : error C2085: 'APIENTRY' : not in formal parameter list
d:\vc98\include\gl\gl.h(1163) : error C2146: syntax error : missing ',' before identifier 'glClearAccum'
d:\vc98\include\gl\gl.h(1163) : error C2143: syntax error : missing ';' before '('
d:\vc98\include\gl\gl.h(1163) : error C2059: syntax error : ')'
d:\vc98\include\gl\gl.h(1164) : error C2054: expected '(' to follow 'WINGDIAPI'
d:\vc98\include\gl\gl.h(1164) : error C2085: 'APIENTRY' : not in formal parameter list
d:\vc98\include\gl\gl.h(1164) : error C2146: syntax error : missing ',' before identifier 'glClearColor'
d:\vc98\include\gl\gl.h(1164) : error C2143: syntax error : missing ';' before '('
d:\vc98\include\gl\gl.h(1164) : error C2059: syntax error : ')'
d:\vc98\include\gl\gl.h(1165) : error C2054: expected '(' to follow 'WINGDIAPI'
d:\vc98\include\gl\gl.h(1165) : error C2085: 'APIENTRY' : not in formal parameter list
d:\vc98\include\gl\gl.h(1165) : error C2146: syntax error : missing ',' before identifier 'glClearDepth'
d:\vc98\include\gl\gl.h(1165) : error C2143: syntax error : missing ';' before '('
d:\vc98\include\gl\gl.h(1165) : error C2059: syntax error : ')'
d:\vc98\include\gl\gl.h(1166) : error C2054: expected '(' to follow 'WINGDIAPI'
d:\vc98\include\gl\gl.h(1166) : error C2085: 'APIENTRY' : not in formal parameter list
d:\vc98\include\gl\gl.h(1166) : error C2146: syntax error : missing ',' before identifier 'glClearIndex'
d:\vc98\include\gl\gl.h(1166) : error C2143: syntax error : missing ';' before '('
d:\vc98\include\gl\gl.h(1166) : error C2059: syntax error : ')'
d:\vc98\include\gl\gl.h(1167) : error C2054: expected '(' to follow 'WINGDIAPI'
d:\vc98\include\gl\gl.h(1167) : error C2085: 'APIENTRY' : not in formal parameter list
d:\vc98\include\gl\gl.h(1167) : error C2146: syntax error : missing ',' before identifier 'glClearStencil'
d:\vc98\include\gl\gl.h(1167) : error C2143: syntax error : missing ';' before '('
d:\vc98\include\gl\gl.h(1167) : error C2059: syntax error : ')'
d:\vc98\include\gl\gl.h(1168) : error C2054: expected '(' to follow 'WINGDIAPI'
d:\vc98\include\gl\gl.h(1168) : error C2085: 'APIENTRY' : not in formal parameter list
d:\vc98\include\gl\gl.h(1168) : error C2146: syntax error : missing ',' before identifier 'glClipPlane'
d:\vc98\include\gl\gl.h(1168) : error C2143: syntax error : missing ';' before '('
d:\vc98\include\gl\gl.h(1168) : error C2059: syntax error : ')'
d:\vc98\include\gl\gl.h(1169) : error C2054: expected '(' to follow 'WINGDIAPI'
d:\vc98\include\gl\gl.h(1169) : error C2085: 'APIENTRY' : not in formal parameter list
d:\vc98\include\gl\gl.h(1169) : error C2146: syntax error : missing ',' before identifier 'glColor3b'
d:\vc98\include\gl\gl.h(1169) : error C2143: syntax error : missing ';' before '('
d:\vc98\include\gl\gl.h(1169) : error C2059: syntax error : ')'
d:\vc98\include\gl\gl.h(1170) : error C2054: expected '(' to follow 'WINGDIAPI'
d:\vc98\include\gl\gl.h(1170) : error C2085: 'APIENTRY' : not in formal parameter list
d:\vc98\include\gl\gl.h(1170) : error C2146: syntax error : missing ',' before identifier 'glColor3bv'
d:\vc98\include\gl\gl.h(1170) : error C2143: syntax error : missing ';' before '('
d:\vc98\include\gl\gl.h(1170) : error C2059: syntax error : ')'
d:\vc98\include\gl\gl.h(1171) : error C2054: expected '(' to follow 'WINGDIAPI'
d:\vc98\include\gl\gl.h(1171) : error C2085: 'APIENTRY' : not in formal parameter list
d:\vc98\include\gl\gl.h(1171) : error C2146: syntax error : missing ',' before identifier 'glColor3d'
d:\vc98\include\gl\gl.h(1171) : error C2143: syntax error : missing ';' before '('
d:\vc98\include\gl\gl.h(1171) : error C2059: syntax error : ')'
d:\vc98\include\gl\gl.h(1172) : error C2054: expected '(' to follow 'WINGDIAPI'
d:\vc98\include\gl\gl.h(1172) : fatal error C1003: error count exceeds 100; stopping compilation
执行 cl.exe 时出错.a.obj - 1 error(s), 0 warning(s)
这个有问题么 ?
// cmdgl.cpp : Defines the entry point for the console application.
//#include "stdafx.h"
#include <GL/glut.h>void myDisplay(void)
{
glClear(GL_COLOR_BUFFER_BIT);
glRectf(-0.5f, -0.5f, 0.5f, 0.5f);
glFlush();
}int main(int argc, char *argv[])
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_RGB | GLUT_SINGLE);
glutInitWindowPosition(100, 100);
glutInitWindowSize(400, 400);
glutCreateWindow("第一个OpenGL程序");
glutDisplayFunc(&myDisplay);
glutMainLoop();
return 0;
}
还要把相关的lib.
#pragma comment(lib,"opengl32.lib")
#pragma comment(lib, "glu32.lib")
...
发生连接错误,应该是lib的问题.