# Errors compiling example code

**URL:** <https://discourse.glfw.org/t/errors-compiling-example-code/603>\
**Category:** support\
**Created:** [August 26, 2013, 5:05pm UTC](https://discourse.glfw.org/t/errors-compiling-example-code/603 "2013-08-26T17:05:17Z")\
**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:** [August 26, 2013, 5:05pm UTC](https://discourse.glfw.org/t/errors-compiling-example-code/603/1 "2013-08-26T17:05:17Z")

</div>

**[cellsheet](https://sourceforge.net/u/cellsheet/)** wrote on [Monday, August 26, 2013](https://sourceforge.net/p/glfw/discussion/247562/thread/3fee40d2/#c259):

Hello, when I had tried to compile the example code for glfw3, I got the following errors:

/tmp/ccCdEKoi.o: In function `main': example.cpp:(.text+0x38): undefined reference to`glfwCreateWindow’  
example.cpp:(.text+0x5b): undefined reference to `glfwMakeContextCurrent' example.cpp:(.text+0x7a): undefined reference to`glfwWindowShouldClose’  
collect2: error: ld returned 1 exit status

I am compiling with g++ example.cpp -o example -lGL -lglfw and when I installed the latest glfw 3.0.2, it installed without problems.

---

<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:** [August 28, 2013, 7:13am UTC](https://discourse.glfw.org/t/errors-compiling-example-code/603/2 "2013-08-28T07:13:08Z")

</div>

**[codesnip3r](https://sourceforge.net/u/codesnip3r/)** wrote on [Wednesday, August 28, 2013](https://sourceforge.net/p/glfw/discussion/247562/thread/3fee40d2/#4c5b):

Looks like you need to link in the glfw library directory.

Try using -L/path/to/glfw
