Static compile under Linux

anonymous wrote on Friday, October 21, 2011:

I’ve been using GLFW just fine under Windows, but now I’m trying to get it
working under Linux. I successfully compiled the library, but I’m having
trouble using it.

1. The included makefile builds both static and dynamic versions of the
library. I’m only interested in the static library, but apparently the dynamic
.so gets used by default. I had to delete it to force use of the static .a
file. Is there a propery way to indicate which one to use?

2. When trying to link my program against the static library, I get a lot of
link errors within libglfw.a, where the linker can’t find a multitude of X11
functions. I tried adding the same $LIBS to the static library that the
dynamic library had, but then I get other errors about missing libraries
(i.e. Xrandr). Am I missing something?

I also looked at the makefiles for the included examples, which build and run
just fine. However, it looks like they include libglfw.a directly, rather than
referencing it as a library. Is libglfw.a not designed to be used as a real

elmindreda wrote on Sunday, October 23, 2011:

1. Replace the -lglfw flag with the path to the static library.

2. The order of libraries matter to the linker. Use the same order as the
examples do.

The -l flag simply means to look in the list of paths.