简体   繁体   English

如果没有“glu.h”和“windows.h”,GLFW 无法编译

[英]GLFW cannot compile without "glu.h" and "windows.h"

I want to create a game engine, but my graphics subsystem will not compile without <GL/glu.h> and <windows.h> .我想创建一个游戏引擎,但如果没有<GL/glu.h><windows.h> ,我的图形子系统将无法编译。

  1. Compiling Graphics.cpp with only <GLFW/glfw3.h> , without both headers will print the error on Graphics.cpp , 'gluErrorString' was not declared in this scope .仅使用<GLFW/glfw3.h>编译Graphics.cpp ,没有两个标头将在Graphics.cpp上打印错误, 'gluErrorString' was not declared in this scope
  2. Compiling Graphics.cpp with <GLFW/glfw3.h> AND '', without <windows.h> will print the error on glu.h , c:\\mingw\\include\\gl\\glu.h|225|error: 'WINGDIAPI' does not name a type .使用<GLFW/glfw3.h>和 '' 编译Graphics.cpp ,没有<windows.h>将在glu.h上打印错误, c:\\mingw\\include\\gl\\glu.h|225|error: 'WINGDIAPI' does not name a type Some workaround I found is to include also the <windows.h> in Graphics.cpp .我发现的一些解决方法是在Graphics.cpp也包含<windows.h>
  3. Compiling Graphics.cpp with <GLFW/glfw3.h> AND '' AND <windows.h> returns no error.使用<GLFW/glfw3.h> AND '' AND <windows.h>编译Graphics.cpp不会返回错误。 The problem is that this program is not cross-platform isn't it?问题是这个程序不是跨平台的不是吗?

As stated in GLFW build guide in the Including the GLFW header file section;Including the GLFW header file部分中的GLFW 构建指南所述; One does not need to include windows.h and OpenGL header files, since GLFW header already included these.不需要包含windows.h和 OpenGL 头文件,因为 GLFW 头文件已经包含了这些。 So I am trying to follow the guide or best practice, and trying to make my game engine cross-platform.所以我正在尝试遵循指南或最佳实践,并尝试使我的游戏引擎跨平台。

Followings are my linker options in CodeBlock,以下是我在 CodeBlock 中的链接器选项,

-lglfw3
-lOpenGL32
-lglu32
-lgdi32

Turns out I only have to write GLFW_INCLUDE_GLU in CodeBlock's compiler settings in the #defines section.原来我只需要在#defines部分的 CodeBlock 编译器设置中编写GLFW_INCLUDE_GLU

Source: Building GLFW program, by Sugih Jamin资料来源: 构建 GLFW 程序,作者:Sugih Jamin

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM