MFC中配置OpenGL所遇到的一些问题
2014-04-24 10:14
232 查看
1.
首先需在stdafx.h中加入以下头文件
此处切记要加在
如果你将Opengl库头文件放在stdafx.h的开始或其他位置
会出现如下连接错误:
c:\program files (x86)\microsoft visual studio\vc98\include\gl\gl.h(1152) : error C2144: syntax error : missing ';' before type 'void'
c:\program files (x86)\microsoft visual studio\vc98\include\gl\gl.h(1152) : error C2501: 'WINGDIAPI' : missing storage-class or type specifiers
c:\program files (x86)\microsoft visual studio\vc98\include\gl\gl.h(1152) : fatal error C1004: unexpected end of file found
一般网上都会教你再加#include <windows.h>
那样的话又会提示“WINDOWS.H already included. ”如此以来便陷入死锁的境地。当然,非MFC的WIN32程序在使用OpenGL时确实应该将#include <windows.h>放在【opengl……】.h之前,这是必须的,但MFC则无须。
关键时opengl配置库文件要放入正确位置。
2:
在C[project]view.h中切记不要随便加入变量,因为MFC中,有好多cpp扩入了C[project]view的头文件,会出现重定义,在配置MFC 中的OpenGL环境是误看了内容,将
HGLRC m_hRC; //Rendering Context
CDC* m_pDC; //Device Context
当做了全局变量放在C[project]view的头文件中,导致Link时出现错误如下:
myOpenGLView.obj : error LNK2005: "struct HGLRC__ * m_hRC" (?m_hRC@@3PAUHGLRC__@@A) already defined in myOpenGL.obj
myOpenGLView.obj : error LNK2005: "class CDC * m_pDC" (?m_pDC@@3P***CDC@@A) already defined in myOpenGL.obj
Creating browse info file....
找到解决办法对于此类“error LNK2005……already defined”的错误,一般而言是因变量重复定义了且又被几个.c(pp)所包含
参考如:点击打开链接
首先需在stdafx.h中加入以下头文件
#include <gl/gl.h> #include <gl/glu.h> #include <gl/glut.h> #include <gl/glaux.h>
此处切记要加在
// _AFX_NO_AFXCMN_SUPPORT //{{AFX_INSERT_LOCATION}} // Microsoft Visual C++ will insert additional declarations immediately before the previous line.之间,“Microsoft Visual C++ will insert additional declarations immediately before the previous line”已提示你要这样做了
如果你将Opengl库头文件放在stdafx.h的开始或其他位置
会出现如下连接错误:
c:\program files (x86)\microsoft visual studio\vc98\include\gl\gl.h(1152) : error C2144: syntax error : missing ';' before type 'void'
c:\program files (x86)\microsoft visual studio\vc98\include\gl\gl.h(1152) : error C2501: 'WINGDIAPI' : missing storage-class or type specifiers
c:\program files (x86)\microsoft visual studio\vc98\include\gl\gl.h(1152) : fatal error C1004: unexpected end of file found
一般网上都会教你再加#include <windows.h>
那样的话又会提示“WINDOWS.H already included. ”如此以来便陷入死锁的境地。当然,非MFC的WIN32程序在使用OpenGL时确实应该将#include <windows.h>放在【opengl……】.h之前,这是必须的,但MFC则无须。
关键时opengl配置库文件要放入正确位置。
2:
在C[project]view.h中切记不要随便加入变量,因为MFC中,有好多cpp扩入了C[project]view的头文件,会出现重定义,在配置MFC 中的OpenGL环境是误看了内容,将
HGLRC m_hRC; //Rendering Context
CDC* m_pDC; //Device Context
当做了全局变量放在C[project]view的头文件中,导致Link时出现错误如下:
myOpenGLView.obj : error LNK2005: "struct HGLRC__ * m_hRC" (?m_hRC@@3PAUHGLRC__@@A) already defined in myOpenGL.obj
myOpenGLView.obj : error LNK2005: "class CDC * m_pDC" (?m_pDC@@3P***CDC@@A) already defined in myOpenGL.obj
Creating browse info file....
找到解决办法对于此类“error LNK2005……already defined”的错误,一般而言是因变量重复定义了且又被几个.c(pp)所包含
参考如:点击打开链接
相关文章推荐
- CodeBlocks配置openGL遇到的一些问题
- 配置OpenGL时遇到的一些问题
- nagios 安装与配置以及遇到一些问题的解决方案
- windows64位配置opengl遇到的问题(eclipse)
- ArcEngine在VS环境下开发遇到的一些配置问题
- CentOS7.0下安装和配置zabbix2.4.5全过程及解决一些遇到的问题
- swift单节点配置遇到的一些问题和解决办法,希望大家补充
- MFC记住上次路径---遇到的一些问题
- 配置hadoop2.2.0时,遇到的一些问题
- windows10 配置caffe 遇到的一些问题
- [项目过程中所遇到的各种问题记录]ORM篇——使用NHibernate配置对象实体的一些小问题
- 在ubuntu中配置java环境变量遇到的一些问题
- 虚拟机网络配置中的一些疑难问题---在实验室遇到了Destination Host Unreachable
- mysql5.7解压版安装配置中遇到的一些问题
- 配置SpringMVC注解遇到的一些小问题
- vim 的配置过程中遇到的一些问题
- apach配置php,cgi支持遇到的一些问题解决方法
- MFC记住上次路径---遇到的一些问题
- MFC下OpenGL编程入门遇到的几个问题总结[1]