How can I continue working on OpenGL with macOS Catalina 10.15.4?

早过忘川 提交于 2021-01-29 16:51:52

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!