I am trying to compile a very simple OpenGL program that uses GLFW3. Despite linking everything I deem necessary, I\'m getting a plethora of undefined references.
I figured out the answer myself while writing the question.
I was misled into believing that I was linking everything necessary because of the output of
pkg-config --libs --cflags --print-requires glfw3
which was
-I/usr/local/include -L/usr/local/lib -lglfw3
The --print-requires
flag was having no impact at all on the output, which seemed odd. I searched and printed the corresponding .pc
file.
sudo find / | grep "glfw3\.pc"
cat /usr/local/lib/pkgconfig/glfw3.pc
There I found this.
Requires.private: x11 xrandr xi xxf86vm gl
Which indicates which libraries are required for static linking. I added their correponding flags to CMake and it worked. My mistake was that I missed the --print-requires-private
flag when executing pkg-config.
I hope this helps someone save some time.