Search code examples
c++g++glfwglewosx-elcapitan

include GLEW, glfw3 and glm using g++ mac


Half a year ago, i was using the libraries glfw3, GLEW and glm to make c++ projects with openGL graphics, and it did work very well, but now i can no longer include these libraries.

When things were working fine, i was able to include the three libraries in my c++ files like this:

#include <GL/glew.h>
#include <glfw3.h>
#include <glm/glm.hpp>

then i could compile the file from my terminal using this line:

g++ in.cpp -o out -lglfw3 -lglew -framework Cocoa -framework OpenGL -framework IOKit -framework CoreVideo

And the result would be working perfectly fine.

I have been working on some not openGL projects for a while, so i'm not sure when exactly it stoped working, but what i do know for sure, is that neither of the libraries can be included know (I have of course tried uninstalling and reinstalling them).

Now however when i try compiling exactly the same way as before the three #include lines produces these errors:

fatal error: 'GL/glew.h' file not found
fatal error: 'glfw3.h' file not found
fatal error: 'glm/glm.hpp' file not found

Obviously g++ cannot find the libraries, but i have no idea why, and how to fix it (I have of course tried uninstalling and reinstalling them, so i know beyond all doubt, that the libraries are positively installed).
I am suspecting that this has to do with El Capitan

sidenote (I am not and has never been writing in and compiling from XCode)


Solution

  • Turned out, that the X-code commandline tools (which i am using even though i am not writing in x-code) had been uninstalled, possibly during the update from Yosemety to El Capitan, i ran this command

    xcode-select --install
    

    And now it seams to be working