Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error: 'GL/glfw3.h: No such file or directory' when compiling C++ programs using OpenGL on Linux

Tags:

c++

linux

opengl

I receive the error message

GL/glfw3.h: No such file or directory

when I try to compile the example program given in the tutorial here, section 'Opening a window'. I have installed all the libraries they referred to in the 'Building on Linux' section. (My distribution is Ubuntu 16.04.)

I have also successfully run

apt-get install libglfw-dev

as I found suggested somewhere as an answer to this issue.

I think the glfw3 library has possibly been installed in a place that the compiler does not know how to automatically access.

How do I find out if this is the case, where should I put it so it can be accessed (/usr/share?), and what exactly do I put there? I've copied a file called libglfw3.a that I found in /usr/local/lib to /usr/share, but the error reoccurred.

I've tried compiling it using g++ first.c -o first and g++ first.c -lglut -lGL -lGLEW -lglfw -o first. That error message alone occurred both times (which makes me think the other libraries don't even need to be linked?)

I'm a pretty new user. The solution is probably obvious.

like image 281
userManyNumbers Avatar asked Aug 13 '16 04:08

userManyNumbers


1 Answers

Easy fix (the solution was indeed obvious).

#include <GL/glfw3.h> should be #include <GLFW/glfw3.h>

like image 90
userManyNumbers Avatar answered Oct 18 '22 02:10

userManyNumbers