Installing deps on Ubuntu

Hi All,

First post. I’ve spent the afternoon trying to correctly install and configure GLFW on my Ubuntu laptop. I’m almost there but I’m missing the final piece to the puzzle. Here’s what I’ve done so far:

I downloaded and extracted to ~/Projects/glfw-3.3.2/


sudo apt-get install cmake xorg-dev
mkdir ~/Projects/glfw-build
cd ~/Projects/glfw-build
cmake ../glfw-3.3.2
sudo make install

So far, so good.

Now, when I try and compile and link the example program at:

I get errors related to glad/gl.h and linmath.h - they can’t be found.

Now, these files (and others) are part of the source package and can be found at:


I’ve trawled through the documentation and CMake files but I can find no clue as to how to correctly install these files. I don’t want to kludge it and just copy them to /usr/local/include - that might work but as the deps folder includes other files, including .c files, I feel sure there’s a “correct” way to proceed. But I can’t find it.

Maybe I’m just supposed to copy the entire deps folder into the root directory of each of my projects. That would work. But it doesn’t feel right.

What am I missing?

To build examples, you can specify extra argument to cmake:
cmake -DGLFW_BUILD_EXAMPLES=YES ../glfw-3.3.2

This will create necessary make commands to build example programs (just running make will build them).

If you don’t want to use cmake to build default examples, then you’ll need to add extra argument to your compiler to specify include folder s to glfw-3.3.2/deps folder. No need to copy files anywhere. Just use -Ipath/to/glfw-3.3.2/deps argument for your compiler.

1 Like

Thanks @mmozeiko, that definitely helped.

But I’m not out of the woods yet though; it’s compiling but not linking. I think I need to trawl through glfw-3.3.2/CMakeLists.txt, glfw-3.3.2/examples/CMakeLists.txt and the makefiles they produce and try and figure out how they work. I’ve not done any programming for almost a decade and I’ve never used CMake before so I have a bit of a learning curve before I can start coding.

Unfortunately, it’s too late here now so it will have to wait until the morning.

Thanks again.

An alternative to installing GLFW is to use it directly from source. If you want to go down that route take a look at our simple GLFW starter example.


Hi @dougbinks,

That worked just fine. I also worked out where at least some of my link errors were coming from - it helps if you install OpenGL!

As an exercise, I replaced main.cpp with simple.c (the example I was originally trying to build) and made the following changes to CMakeLists.txt:

# Add deps
include_directories( "glfw/deps" )

set(GLAD_GL "${GLFW_SOURCE_DIR}/deps/glad/gl.h"
set(GETOPT "${GLFW_SOURCE_DIR}/deps/getopt.h"
set(TINYCTHREAD "${GLFW_SOURCE_DIR}/deps/tinycthread.h"
# End deps

# Add glad
add_executable( GLFW-CMake-starter ${GLFW-CMAKE-STARTER-SRC} ${GLAD_GL})

And that worked too. So now I just have to work out how :smiley: