Home>

Using the GLFW3 library using gcc at the mac terminal
I would like to do OpenGL programming, but even if GLFW3 is included, "The file does not exist"
I get an error. I tried a lot of trial and error, but my heart was about to break, so here
I will ask a question.

What I did for the time being
  • Download the GLFW source code
  • Create makefile using Cmake
  • Create GLFW library from makefile
  • I wrote the source code to see if it works
# include "GLFW/glfw3.h"
int main (void)
{
  GLFWwindow * window;
  if (! glfwInit ()) return -1;
  window = glfwCreateWindow (640, 480, "Hello, World", NULL, NULL);
  if (! window) {
    glfwTerminate ();
    return -1;
  }
  glfwMakeContextCurrent (window);
  while (! glfwWindowShouldClose (window)) {
    glClear (GL_COLOR_BUFFER_BIT);
    glfwSwapBuffers (window);
    glfwPollEvents ();
  }
  glfwTerminate ();
  return 0;
}
The command to compile is suspicious

I'm worried about whether the command itself should be

$gcc main.cpp -framework OpenGL
main.cpp: 1: 10: fatal error: 'GLFW/glfw3.h' file not found
#include "GLFW/glfw3.h"
         ^
1 error generated.