# How to get GLFW programs to link on Linux (undefined refrences)

**URL:** <https://discourse.glfw.org/t/how-to-get-glfw-programs-to-link-on-linux-undefined-refrences/579>\
**Category:** support\
**Created:** [June 16, 2013, 7:03am UTC](https://discourse.glfw.org/t/how-to-get-glfw-programs-to-link-on-linux-undefined-refrences/579 "2013-06-16T07:03:48Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex035/uploads/glfw/original/1X/b8cdefe6b61b8d5aee6c43b2c56e9cf5eabecfe4.svg) [@system](https://discourse.glfw.org/u/system)\
**Post date:** [June 16, 2013, 7:03am UTC](https://discourse.glfw.org/t/how-to-get-glfw-programs-to-link-on-linux-undefined-refrences/579/1 "2013-06-16T07:03:48Z")

</div>

**[gyroninja](https://sourceforge.net/u/gyroninja/)** wrote on [Sunday, June 16, 2013](https://sourceforge.net/p/glfw/discussion/247562/thread/918934c7/#7053):

After hours of frustrating work I finally got the linker to work and compile my programs with GLFW. In this format and order of libraries.

“g++ -o dist/Debug/GNU-Linux-x86/tuxgui build/Debug/GNU-Linux-x86/main.o `pkg-config --libs glfw3` `pkg-config --libs gl` `pkg-config --libs xext` `pkg-config --libs x11` `pkg-config --libs xrandr` `pkg-config --libs xxf86vm` `pkg-config --libs xi` -lpthread”

So you need to load the libraries in this order. “glfw, gl, xext, x11, xrandr, xxf86vm, xi, and pthread” This problem caused me hours of trouble so I hope this help someone.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex035/uploads/glfw/original/1X/b8cdefe6b61b8d5aee6c43b2c56e9cf5eabecfe4.svg) [@system](https://discourse.glfw.org/u/system)\
**Post date:** [June 16, 2013, 12:01pm UTC](https://discourse.glfw.org/t/how-to-get-glfw-programs-to-link-on-linux-undefined-refrences/579/2 "2013-06-16T12:01:59Z")

</div>

**[elmindreda](https://sourceforge.net/u/elmindreda/)** wrote on [Sunday, June 16, 2013](https://sourceforge.net/p/glfw/discussion/247562/thread/918934c7/#475b):

If you are using the static version of the GLFW library then you need to use the `--static` flag.
