VC2010配置OpenGL常见问题

来源:互联网 发布:茶水浇花知乎 编辑:程序博客网 时间:2024/05/21 10:48

我不信没有你的菜

 

一、Visual C++ 2010入门教程》系列二:安装、配置和首次使用VS2010

http://www.cnblogs.com/Mrt-02/archive/2011/07/24/2115617.html

 

二、安装GLUT工具包

GLUT不是OpenGL所必须的,但它会给我们的学习带来一定的方便,推荐安装。

Windows环境下的GLUT下载地址:(大小约为150k)

http://www.opengl.org/resources/libraries/glut/glutdlls37beta.zip

无法从以上地址下载的话请使用下面的连接:

http://upload.programfan.com/upfile/200607311626279.zip

 

Windows环境下安装GLUT的步骤:

1、将下载的压缩包解开,将得到5个文件,分别是glut.h,glut.lib,glut32.lib,glut.dll,glut32.dll

2、将其中的glut.h放到C:\Program Files\Microsoft SDKs\Windows\v7.0A\Include\gl里面,VS2010会自动搜索这个路径。

3. 将glut.lib和glut32.lib复制到F:\vs2010\VC\lib下,根据VS2010的具体安装路径确定。

4. 将glut.dll和glut32.dll复制到C:\WINDOWS\system32下。

至此,环境已经配置好了。

 

三、创建工程项目

1. 新建->项目->win32控制台应用程序。

2. 输入项目名:simpleGL,其他默认即可。

3. 输入源代码:

#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 _tmain(int argc, _TCHAR* argv[])

{

    glutInitDisplayMode(GLUT_RGB | GLUT_SINGLE);

    glutInitWindowPosition(100, 100);

    glutInitWindowSize(400, 400);

    glutCreateWindow("第一个OpenGL程序");

    glutDisplayFunc(&myDisplay);

    glutMainLoop();

     return 0;

}

4、设置IDE环境:

链接OpenGL libraries。在Visual C++中先右击项目,选择属性,找到连接器标签,最后在输入中的附加依赖库加上opengl32.lib glut32.lib glu32.lib.

5、编译运行,注意如果F5不行就按Ctrl+F5

http://blog.csdn.net/lixam/article/details/7618015

http://blog.csdn.net/urkyyang/article/details/5418583


三、常见问题

1、VC++编译错误为Cannot open include file: 'stdafx.h': No such file or directory,怎么解决?

1) #include <stdafx.h> 去掉好啦,不影响的。这个是建一个自动工程时自动生成的,不用也可以。

 2)另外一种解决方法:你新建一个工程,选择默认的选项,然后你的工程里面就有这个头文件(#include <stdafx.h>)啦

如果还不能解决你的问题,请看http://blog.sina.com.cn/s/blog_5bbeb71a0100hpyd.html

 

2、LINK : fatal error LNK1123: failure during conversion to COFF: file invalid or corrupt解决方法:

项目-->工程属性->配置属性-> 清单工具->输入和输出->嵌入清单,选择[否]   ----------->只要设这个就可以了

项目-->项目属性-->配置属性-->清单工具-->使用FAT32解决方法为 是;

http://tenz.blog.163.com/blog/static/60802417201231093752741/

 

 

3、OpenGL程序无法启动此应用程序,因为计算机中丢失glut32.dll

解决方法:

查看Windows目录,发现在system32同级的目录还有一个目录:SysWOW64

原先配置时是,把解压得到的glut.dll和glut32.dll放到操作系统目录下面的system32文件夹内。(典型的位置为:C:WindowsSystem32)。

现在出现这种问题时,应该将glut.dll和glut32.dll放到操作系统目录下面的C:WindowsSysWOW64文件夹内,这时再编译就没有问题了。

http://www.gimoo.net/t/1506/557e80da9079f.html

http://blog.csdn.net/tyxkzzf/article/details/40789901

 

4、Cannot find or open the PDB file

“TCPSrv.exe”: 已加载“D:\MFC\TCPSrv\Debug\TCPSrv.exe”,已加载符号。

“TCPSrv.exe”: 已加载“C:\Windows\System32\ntdll.dll”,Cannot find or open the PDB file

“TCPSrv.exe”: 已加载“C:\Windows\System32\kernel32.dll”,Cannot find or open the PDB file

“TCPSrv.exe”: 已加载“C:\Windows\System32\KernelBase.dll”,Cannot find or open the PDB file

“TCPSrv.exe”: 已加载“C:\Windows\System32\msvcr100d.dll”,已加载符号。

“TCPSrv.exe”: 已加载“C:\Windows\System32\ws2_32.dll”,Cannot find or open the PDB file

“TCPSrv.exe”: 已加载“C:\Windows\System32\msvcrt.dll”,Cannot find or open the PDB file

“TCPSrv.exe”: 已加载“C:\Windows\System32\rpcrt4.dll”,Cannot find or open the PDB file

“TCPSrv.exe”: 已加载“C:\Windows\System32\nsi.dll”,Cannot find or open the PDB file

“TCPSrv.exe”: 已加载“C:\Windows\System32\mswsock.dll”,Cannot find or open the PDB file

“TCPSrv.exe”: 已加载“C:\Windows\System32\user32.dll”,Cannot find or open the PDB file

“TCPSrv.exe”: 已加载“C:\Windows\System32\gdi32.dll”,Cannot find or open the PDB file

“TCPSrv.exe”: 已加载“C:\Windows\System32\lpk.dll”,Cannot find or open the PDB file

“TCPSrv.exe”: 已加载“C:\Windows\System32\usp10.dll”,Cannot find or open the PDB file

“TCPSrv.exe”: 已加载“C:\Windows\System32\imm32.dll”,Cannot find or open the PDB file

“TCPSrv.exe”: 已加载“C:\Windows\System32\msctf.dll”,Cannot find or open the PDB file

“TCPSrv.exe”: 已加载“C:\Windows\System32\WSHTCPIP.DLL”,Cannot find or open the PDB file

线程 'Win32 线程' (0xeb4) 已退出,返回值为 -1073741510 (0xc000013a)。

程序“[3704] TCPSrv.exe: 本机”已退出,返回值为 -1073741510 (0xc000013a)。

 

解决方法:

1)原因是程序输出的地方是系统而不是vs2010。

Ctrl + F5运行就可以了

或者在cmd命令行下执行程序。

2)"Microsoft Symbol Servers"勾上(Tools -> Options -> Debugging -> Symbols)

第二种方法可能设置了还是不行,推荐直接用方法1;微软专业人士解答,如果没有必要非要在windows下编译某些内容,是不需要加载这些符号文件的,这样反而会减慢编译速度

http://connect.microsoft.com/VisualStudio/feedback/details/567082/-debug-cannot-find-or-open-the-pdb-file

http://bbs.csdn.net/topics/350149584

“kernel32.dll”,Cannot find or open the PDB file

如果你拿到这个DLL的调试信息和源代码,那就拿到了Windows的核心,所以,是不可能找到的。)

 

 

 

5、vs2010 无法启动程序 系统找不到指定的文件

解决办法如下:

"菜单--->项目--->属性--->配置属性---->链接器---->清单文件---->生成清单" 设置为"是"

再重新生成解决方案, 重新生成可执行程序,然后就搞定了...

还有,确定好输出目录的位置:配置属性-->常规-->输出目录, 与其它依赖的dll文件相对路径的问题.

http://blog.csdn.net/cai_huan_123/article/details/32130999

http://blog.chinaunix.net/uid-25958655-id-4230337.html

 

四、以上都是许多大神的智慧结晶,我只是搬运工,希望能与大家一同分享

0 0
原创粉丝点击