简体   繁体   English

不能再包含GLEW,Mac,不是XCode

[英]cannot include GLEW anymore, Mac, Not XCode

I am using a mac, but i am not programming in XCode 我正在使用Mac,但未在XCode中编程

A few months ago i was trying to learn to use OpenGL in C++, and it did work quite well. 几个月前,我试图学习在C ++中使用OpenGL,并且确实运行良好。 I was using the GLFW, GLEW and GLM libraries, and i was able to write .cpp files, that i could compile and run without problems, and which did work exactly as intended. 我使用的是GLFW,GLEW和GLM库,并且能够编写.cpp文件,这样我可以毫无问题地进行编译和运行,并且确实按预期工作。
I was writing my .cpp files in a text editor which is not XCode, and i was compiling from the terminal using this line: 我在不是XCode的文本编辑器中编写了.cpp文件,并且使用以下命令行从终端进行了编译:

g++ input.cpp -o output -lglfw3 -lglew -framework Cocoa -framework OpenGL -framework IOKit -framework CoreVideo

I included the GLEW library using this line: 我使用此行包括了GLEW库:

#include <GL/glew.h>  

and it did work perfectly 它确实运行良好

Then i spend a few month on some other projects, which did not use openGL, and now i am planning to do something that does require openGL, and i am still not using XCode and i am still compiling using the terminal the exact same way, but now i get this error, when compiling on the terminal using the line i mentioned before: 然后,我花了几个月的时间在其他一些没有使用openGL的项目上,现在我打算做一些需要openGL的项目,而我仍然没有使用XCode,并且我仍然使用完全相同的方式使用终端进行编译,但是现在我在使用前面提到的行在终端上进行编译时收到此错误:

 fatal error: 'GL/GLEW.h' file not found

This even happens, when i try compilling old projects, which worked perfectly, without causing error when including GLEW, month ago, even though i didn't change anything. 即使当我尝试编译旧项目时,即使在我没有进行任何更改的情况下,它都能很好地工作,并且在一个月前包括GLEW时也不会引起错误,甚至发生了这种情况。

To be perfectly clear 完全清楚

#include <GL/glew.h>  

Did yes a few month ago include GLEW without causing any errors, but now it doesn't work, and now it does cause this error: 的,几个月前是否包含GLEW而不引起任何错误,但是现在它不起作用 ,现在确实导致了此错误:

 fatal error: 'GL/GLEW.h' file not found

My question is then; 我的问题是; Why can't i include GLEW like i used to, and how am i supposed to include GLEW now? 为什么我不能像以前那样包含GLEW?现在应该如何包含GLEW? Does this have anything to do with the latest updates of the system (el capitan)? 这与系统的最新更新(el capitan)有关吗? Will i have to use a library which is not GLEW ? 我需要使用不是GLEW的库吗? Or will i to be able to use openGL in C++ have to stop using mac or start start using XCode? 还是要能够在C ++中使用openGL,必须停止使用Mac还是开始使用XCode开始?

note: I am 100% sure: that i have GLEW installed; 注意:我100%确信:我已经安装了GLEW; that i was able to include GLEW before; 我以前能够加入GLEW; and that it was possible to compile .cpp files on mac from terminal even, though openGL was used, and the file where not written in XCode. 而且即使使用openGL,也可以从终端在Mac上编译.cpp文件,并且该文件用XCode编写。

我只是意识到问题不仅出在GLEW上,GLM或glfw3都无法正常工作,而且它似乎表明我用来安装这些库(自制程序)的程序包管理器在我的系统(OS X 10.11。El)上不起作用。 Capitan),我不确定是什么问题,我将永远不会完全解决这个问题,但是我最初的问题现在已经解决了。

<GL/glew.h> is not a standard header file on Mac OS. <GL/glew.h>在Mac OS上不是标准头文件。 Meaning, it's not part of the system or Xcode installation. 意思是,它不是系统或Xcode安装的一部分。 If you previously had it on your system, it was part of something you installed in addition to the standard development tools. 如果您以前在系统上安装过它,那么它是标准开发工具之外还安装的一部分。

Chances are that whatever package you previously installed to get <GL/glew.h> is not on your current system. <GL/glew.h>您先前安装的用于获取<GL/glew.h>任何软件包都不在当前系统上。 You will have to install it explicitly, and make sure that the location you install it to is part of your include path. 您将必须明确安装它,并确保将其安装到的位置是包含路径的一部分。

That said, GLEW is absolutely unnecessary on Mac OS. 也就是说,在Mac OS上绝对不需要GLEW。 It is used for extension loading on systems that do not have headers/libraries for current OpenGL versions (like Windows and Linux). 它用于在没有用于当前OpenGL版本(例如Windows和Linux)的标头/库的系统上的扩展加载。 On Mac OS, there are headers and libraries that contain all the entry points for the OpenGL version supported by the system. 在Mac OS上,有些标头和库包含系统支持的OpenGL版本的所有入口点。 An extension loader servers no useful purpose. 扩展加载程序服务器无用。

So the easiest solution is to simply remove/disable all GLEW dependencies when you're building on Mac OS. 因此,最简单的解决方案是在Mac OS上构建时简单地删除/禁用所有GLEW依赖项。

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

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