# Link error on linux

**URL:** <https://discourse.glfw.org/t/link-error-on-linux/1536>\
**Category:** support\
**Created:** [April 15, 2020, 8:04am UTC](https://discourse.glfw.org/t/link-error-on-linux/1536 "2020-04-15T08:04:02Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Hooman3](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.glfw.org/hooman3/32/325_2.png) [@Hooman3](https://discourse.glfw.org/u/Hooman3)\
**Post date:** [April 15, 2020, 8:04am UTC](https://discourse.glfw.org/t/link-error-on-linux/1536/1 "2020-04-15T08:04:02Z")

</div>

i have problem with compiling :

gcc ~/test.cpp  
/usr/bin/ld: /tmp/cc4hXN39.o: in function `main': test.cpp:(.text+0x5): undefined reference to `glfwInit’  
collect2: error: ld returned 1 exit status

the file only consist of \<GLFW/glfw3.h\>  
and glfwInit();

---

<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:** [April 15, 2020, 8:58am UTC](https://discourse.glfw.org/t/link-error-on-linux/1536/2 "2020-04-15T08:58:33Z")

</div>

You need to link against glfw, see the [GLFW building applications guide](https://www.glfw.org/docs/latest/build_guide.html).

If you don’t mind using cmake to generate your makefiles then take a look at:

> **[juliettef/GLFW-CMake-starter](https://github.com/juliettef/GLFW-CMake-starter)**
>
> Use CMake to create a project with GLFW - Multi-platform Windows, Linux and MacOS. - juliettef/GLFW-CMake-starter

---

<div class="post-metadata">

**Author:** ![Hooman3](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.glfw.org/hooman3/32/325_2.png) [@Hooman3](https://discourse.glfw.org/u/Hooman3)\
**Post date:** [April 15, 2020, 10:49am UTC](https://discourse.glfw.org/t/link-error-on-linux/1536/3 "2020-04-15T10:49:59Z")

</div>

starter will open a window right ? it didn’t work on that way, but i make install them. and all is good in /usr/lib directory but still can’t link

---

<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:** [April 15, 2020, 11:08am UTC](https://discourse.glfw.org/t/link-error-on-linux/1536/4 "2020-04-15T11:08:36Z")

</div>

After `make all` you should see a program called `GLFW-CMAKE-starter` which you can run - I’ll get the readme changed to reflect that.

---

<div class="post-metadata">

**Author:** ![Hooman3](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.glfw.org/hooman3/32/325_2.png) [@Hooman3](https://discourse.glfw.org/u/Hooman3)\
**Post date:** [April 15, 2020, 11:23am UTC](https://discourse.glfw.org/t/link-error-on-linux/1536/5 "2020-04-15T11:23:02Z")

</div>

thanks it’s working well.
