简体   繁体   中英

cannot include GLEW anymore, Mac, Not XCode

I am using a mac, but i am not programming in XCode

A few months ago i was trying to learn to use OpenGL in C++, and it did work quite well. 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.
I was writing my .cpp files in a text editor which is not XCode, and i was compiling from the terminal using this line:

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

I included the GLEW library using this line:

#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:

 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.

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:

 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? Does this have anything to do with the latest updates of the system (el capitan)? Will i have to use a library which is not GLEW ? Or will i to be able to use openGL in C++ have to stop using mac or start start using XCode?

note: I am 100% sure: that i have GLEW installed; that i was able to include GLEW before; 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.

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

<GL/glew.h> is not a standard header file on Mac OS. Meaning, it's not part of the system or Xcode installation. 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. 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. It is used for extension loading on systems that do not have headers/libraries for current OpenGL versions (like Windows and Linux). On Mac OS, there are headers and libraries that contain all the entry points for the OpenGL version supported by the system. 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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