# Linking failure, -lglfw missing

**URL:** <https://discourse.glfw.org/t/linking-failure-lglfw-missing/2765>\
**Category:** support\
**Created:** [October 16, 2024, 7:51pm UTC](https://discourse.glfw.org/t/linking-failure-lglfw-missing/2765 "2024-10-16T19:51:46Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![qy9](https://avatars.discourse-cdn.com/v4/letter/q/e9c0ed/32.png) [@qy9](https://discourse.glfw.org/u/qy9)\
**Post date:** [October 16, 2024, 7:51pm UTC](https://discourse.glfw.org/t/linking-failure-lglfw-missing/2765/1 "2024-10-16T19:51:46Z")

</div>

I tried my best to follow official documentation and failed. So this isn’t my lazyness, I am seriously struggling.

I am trying to install GLFW 3.4 because it has wayland support. I use debian and it only supplies GLFW 3.3 so I need to compile my own. _(I tried the package called `glfw-wayland` but that didn’t go well as my window didn’t even open.)_

I got the `glfw-3.4.zip`, extracted the contents to `./glfw-3.4`  
then I ran `cmake -S . -B ./build -D GLFW_BUILD_X11=0`  
this should generate the makefiles for glfw in the directory `./glfw-3.4/build`. Finally I ran `cd build` and `make` to compile. No errors appeared.  
I open the directory and there was nothing inside, I was expecting something like glfw.dll or glfw.lib to appear but there was nothing.

To see if it was placed in the regular path I just needed it compile my project. The documentation asked me to add `-I./glfw-3.4/include/` this piece of code for the header file, it worked fine. I now I am left at the part where it says `/usr/bin/ld: cannot find -lglfw: No such file or directory`

Now there is two options, either the compilation failed or the library is at an unknown location. Either way there official documentation doesn’t tell me how to proceed.

UPDATE 1:

Someone told me to use `sudo make install` that indeed was a good idea and now I get

```auto
gcc -std=c17 -Wall -Wextra -Wpedantic -Wconversion -Warith-conversion -g -o vtest real.c -I/usr/local/include -L/usr/local/lib -lglfw3 -lvulkan -ldl -lpthread -lX11 -lXxf86vm -lXrandr -lXi
/usr/bin/ld: /usr/local/lib/libglfw3.a(x11_monitor.c.o): undefined reference to symbol 'round@@GLIBC_2.2.5'
/usr/bin/ld: /lib/x86_64-linux-gnu/libm.so.6: error adding symbols: DSO missing from command line

```

I wonder why it’s so broken

---

<div class="post-metadata">

**Author:** ![dougbinks](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.glfw.org/dougbinks/32/39_2.png) [@dougbinks](https://discourse.glfw.org/u/dougbinks)\
**Post date:** [October 17, 2024, 7:38am UTC](https://discourse.glfw.org/t/linking-failure-lglfw-missing/2765/2 "2024-10-17T07:38:24Z")

</div>

Building applications on Linux systems with `make` can be a bit of a pain, I would recommend taking a look at either using [pkg-config as per our build guide](https://www.glfw.org/docs/latest/build_guide.html#build_link_pkgconfig) or using [CMake like in this GLFW CMake Starter](https://github.com/enkisoftware/GLFW-CMake-starter).

---

<div class="post-metadata">

**Author:** ![qy9](https://avatars.discourse-cdn.com/v4/letter/q/e9c0ed/32.png) [@qy9](https://discourse.glfw.org/u/qy9)\
**Post date:** [October 21, 2024, 12:46am UTC](https://discourse.glfw.org/t/linking-failure-lglfw-missing/2765/3 "2024-10-21T00:46:35Z")

</div>

I fixed it, `-lm` flag was needed _after_ `-glfw3` not before. I am writing this incase it helps someone in the future.
