好的,所以我最近获得了OpenGL SuperBible,并将 Code :: Blocks 上的目录设置为freeglut
和GLTools.h
,但这些{{1} }语句不起作用:
#include
设置我浏览“设置”的目录 - > “编译器和调试器......” - > “搜索目录”选项卡并将其添加到“编译器”选项卡下(还有“链接器”和“资源编译器”选项卡):
#include <GLtools.h>
#include <GLShaderManager.h>
#include <iostream>
#include <GL/glut.h>
和
C:\CodeBlocks\SB5\Src\GLTools\include
这些是我得到的错误:
C:\CodeBlocks\SB5\freeglut-2.6.0\include
看起来好像头文件之间存在某种冲突,但是当我甚至没有包含它时,它会在C:\CodeBlocks\SB5\freeglut-2.6.0\include\GL\freeglut_std.h|60|warning: "NOMINMAX" redefined|
c:\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.4.1\include\c++\mingw32\bits\os_defines.h|46|warning: this is the location of the previous definition|
c:\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.4.1\..\..\..\..\include\GL\glu.h|225|error: expected constructor, destructor, or type conversion before 'void'|
c:\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.4.1\..\..\..\..\include\GL\glu.h|226|error: expected constructor, destructor, or type conversion before 'void'|
c:\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.4.1\..\..\..\..\include\GL\glu.h|227|error: expected constructor, destructor, or type conversion before 'void'|
c:\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.4.1\..\..\..\..\include\GL\glu.h|228|error: expected constructor, destructor, or type conversion before 'void'|
c:\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.4.1\..\..\..\..\include\GL\glu.h|229|error: 'GLAPI' does not name a type|
c:\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.4.1\..\..\..\..\include\GL\glu.h|230|error: 'GLAPI' does not name a type|
c:\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.4.1\..\..\..\..\include\GL\glu.h|231|error: expected constructor, destructor, or type conversion before 'void'|
c:\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.4.1\..\..\..\..\include\GL\glu.h|232|error: expected constructor, destructor, or type conversion before 'void'|
c:\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.4.1\..\..\..\..\include\GL\glu.h|233|error: expected constructor, destructor, or type conversion before 'void'|
c:\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.4.1\..\..\..\..\include\GL\glu.h|234|error: expected constructor, destructor, or type conversion before 'void'|
c:\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.4.1\..\..\..\..\include\GL\glu.h|235|error: expected constructor, destructor, or type conversion before 'void'|
c:\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.4.1\..\..\..\..\include\GL\glu.h|236|error: expected constructor, destructor, or type conversion before 'void'|
c:\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.4.1\..\..\..\..\include\GL\glu.h|237|error: expected constructor, destructor, or type conversion before 'void'|
c:\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.4.1\..\..\..\..\include\GL\glu.h|238|error: expected constructor, destructor, or type conversion before 'void'|
c:\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.4.1\..\..\..\..\include\GL\glu.h|239|error: expected constructor, destructor, or type conversion before 'void'|
c:\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.4.1\..\..\..\..\include\GL\glu.h|240|error: expected constructor, destructor, or type conversion before 'const'|
c:\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.4.1\..\..\..\..\include\GL\glu.h|241|error: expected constructor, destructor, or type conversion before 'const'|
c:\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.4.1\..\..\..\..\include\GL\glu.h|242|error: expected constructor, destructor, or type conversion before 'void'|
c:\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.4.1\..\..\..\..\include\GL\glu.h|243|error: expected constructor, destructor, or type conversion before 'const'|
c:\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.4.1\..\..\..\..\include\GL\glu.h|244|error: expected constructor, destructor, or type conversion before 'void'|
c:\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.4.1\..\..\..\..\include\GL\glu.h|245|error: expected constructor, destructor, or type conversion before 'void'|
c:\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.4.1\..\..\..\..\include\GL\glu.h|246|error: expected constructor, destructor, or type conversion before 'void'|
c:\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.4.1\..\..\..\..\include\GL\glu.h|247|error: 'GLAPI' does not name a type|
c:\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.4.1\..\..\..\..\include\GL\glu.h|248|error: 'GLAPI' does not name a type|
c:\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.4.1\..\..\..\..\include\GL\glu.h|249|error: 'GLAPI' does not name a type|
c:\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.4.1\..\..\..\..\include\GL\glu.h|250|error: expected constructor, destructor, or type conversion before 'void'|
c:\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.4.1\..\..\..\..\include\GL\glu.h|251|error: expected constructor, destructor, or type conversion before 'void'|
c:\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.4.1\..\..\..\..\include\GL\glu.h|252|error: expected constructor, destructor, or type conversion before 'void'|
c:\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.4.1\..\..\..\..\include\GL\glu.h|253|error: expected constructor, destructor, or type conversion before 'void'|
c:\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.4.1\..\..\..\..\include\GL\glu.h|254|error: expected constructor, destructor, or type conversion before 'void'|
c:\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.4.1\..\..\..\..\include\GL\glu.h|255|error: expected constructor, destructor, or type conversion before 'void'|
c:\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.4.1\..\..\..\..\include\GL\glu.h|256|error: expected constructor, destructor, or type conversion before 'void'|
c:\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.4.1\..\..\..\..\include\GL\glu.h|257|error: expected constructor, destructor, or type conversion before 'void'|
c:\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.4.1\..\..\..\..\include\GL\glu.h|258|error: expected constructor, destructor, or type conversion before 'void'|
c:\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.4.1\..\..\..\..\include\GL\glu.h|259|error: 'GLAPI' does not name a type|
c:\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.4.1\..\..\..\..\include\GL\glu.h|260|error: expected constructor, destructor, or type conversion before 'void'|
c:\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.4.1\..\..\..\..\include\GL\glu.h|261|error: expected constructor, destructor, or type conversion before 'void'|
c:\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.4.1\..\..\..\..\include\GL\glu.h|262|error: expected constructor, destructor, or type conversion before 'void'|
c:\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.4.1\..\..\..\..\include\GL\glu.h|263|error: expected constructor, destructor, or type conversion before 'void'|
c:\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.4.1\..\..\..\..\include\GL\glu.h|264|error: expected constructor, destructor, or type conversion before 'void'|
c:\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.4.1\..\..\..\..\include\GL\glu.h|265|error: expected constructor, destructor, or type conversion before 'void'|
c:\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.4.1\..\..\..\..\include\GL\glu.h|266|error: 'GLAPI' does not name a type|
c:\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.4.1\..\..\..\..\include\GL\glu.h|267|error: expected constructor, destructor, or type conversion before 'void'|
c:\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.4.1\..\..\..\..\include\GL\glu.h|268|error: expected constructor, destructor, or type conversion before 'void'|
c:\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.4.1\..\..\..\..\include\GL\glu.h|269|error: expected constructor, destructor, or type conversion before 'void'|
c:\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.4.1\..\..\..\..\include\GL\glu.h|270|error: expected constructor, destructor, or type conversion before 'void'|
c:\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.4.1\..\..\..\..\include\GL\glu.h|271|error: expected constructor, destructor, or type conversion before 'void'|
c:\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.4.1\..\..\..\..\include\GL\glu.h|272|error: expected constructor, destructor, or type conversion before 'void'|
c:\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.4.1\..\..\..\..\include\GL\glu.h|273|error: expected constructor, destructor, or type conversion before 'void'|
c:\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.4.1\..\..\..\..\include\GL\glu.h|274|error: expected constructor, destructor, or type conversion before 'void'|
||More errors follow but not being shown.|
||Edit the max errors limit in compiler options...|
||=== Build finished: 50 errors, 2 warnings ===|
出现错误。
请帮忙!谢谢! =)
答案 0 :(得分:14)
答案 1 :(得分:0)
在测试几个教程中的代码时,几天来一直在努力解决这个问题。我想这是因为它们大部分是用Visual C / C ++制作的,但我真的想用C :: B和MinGW来完成这项任务。
想想我终于找到了解决这个问题的简单方法:
1)如果您尚未能为minGW正确安装freeglut-2.6.0,请尝试从此处抓取它:
http://files.transmissionzero.co.uk/software/development/GLUT/freeglut-MinGW.zip
解压缩并为您的项目提供.h和.a文件。保存.dll以供日后使用。
2)在包括glut.h之前添加这两个定义
#define GLUT_DISABLE_ATEXIT_HACK
#define GLAPI extern
#include <GL/glut.h>
3)编译项目
4)在运行可执行文件之前,将freeglut.dll复制到其目录
5)快乐GL黑客(最后!)