问题
I am trying to work with OpenGL on macOS Catalina 10.15.4 but there is a error;
GL/glew.h
GL/freeglut.h
file not found!
My code
// main.cpp
#include"GL/glew.h" // error; 'GL/glew.h' file not found
#include"GL/freeglut.h" // error; 'GL/freeglut.h' file not found
#include<iostream>
#define GLEW_STATIC
void display(void) { }
int main(int argc, char *argv[]) {
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DEPTH | GLUT_DOUBLE | GLUT_RGBA);
glutInitWindowPosition(500, 200);
glutInitWindowSize(500, 350);
glutCreateWindow("OpenGL Merhaba Dunya");
glutDisplayFunc(display);
glutMainLoop();
}
frameworks & libraries tab on Xcode;
Build phases tab on Xcode;
Header search path;
My friend has a lower version on his Mac and he can work on it. But my Mac up to date but I can't work?
I am working with OpenGL (c++)
回答1:
These files come from third-party packages.
Install them with brew install glew freeglut
.
Tell your friend to avoid freeglut, it is showing its age. Use SDL2 or GLFW instead.
回答2:
I change the path from;
/usr/locale/include
to;
/usr/local/include
thanks to @Botje
回答3:
Im using macOS Catalina v10.15.7 and I referred to two resources that helped me to set up freeglut, glew, glfw, and glm namely:
https://www.youtube.com/watch?v=VbBePBp_NbY&ab_channel=SticksStudios and http://macappstore.org/glm/
Basically, you can use homebrew to install all four libraries separately.
brew install freeglut
brew install glew
brew install glfw
brew install glm
For glm, you're pretty much done and can just add this header #include <glm/glm.hpp>
above main.cpp file to start using it. As for glew and glfw, you may refer to the youtube video by Sticks Studios above for a better explanation of the configurations to do.
来源:https://stackoverflow.com/questions/61524399/how-can-i-continue-working-on-opengl-with-macos-catalina-10-15-4