最近在学图像处理
用的是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)。
现在,准备工作基本上完成了,可不要轻视这一步,如果你没有设置好在编译及运行过程中总会出错的。 还要怎么设置么 ??

解决方案 »

  1.   

    你的设置步骤基本上是对的,但是你加进去的库有点少,如果你的OPENGL程序用到的其他库的函数的话就会报错,你看看你的程序有没有用到其他的库?或者你到网上下载其他的库,或者你给邮件给我,我发给你:[email protected]
      

  2.   


    #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)
    帮忙看一下为什么出问题啊 
      

  3.   

    连接错误的问题,你再加上下面三个头文件试试!
    #include <GL/gl.h>
    #include <GL/glut.h>
    #include <GL/glaux.h>
      

  4.   

    加了后为什么头文件报错?d:\vc98\include\gl\gl.h(1152) : error C2054: expected '(' to follow 'WINGDIAPI'
    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)
      

  5.   

    这个gl.h我用我下载的把原来VC下来有的这个文件覆盖了
    这个有问题么 ?
      

  6.   

    我用vc6.0生成一个"hello worlde"控制台工程,未做任何设置,直接将楼主贴出的代码复制粘贴,编译通过,运行正常,以下是我的全部代码:
    // 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;
    }
      

  7.   

    应该要包含gl.h的 它包含opengl的一些基本的函数的声明.
    还要把相关的lib.
    #pragma comment(lib,"opengl32.lib")
    #pragma comment(lib, "glu32.lib")
    ...
    发生连接错误,应该是lib的问题.