# I get a link error

**URL:** <https://discourse.glfw.org/t/i-get-a-link-error/1926>\
**Category:** support\
**Created:** [October 4, 2021, 1:25am UTC](https://discourse.glfw.org/t/i-get-a-link-error/1926 "2021-10-04T01:25:22Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Shigurechan](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.glfw.org/shigurechan/32/557_2.png) [@Shigurechan](https://discourse.glfw.org/u/Shigurechan)\
**Post date:** [October 4, 2021, 1:25am UTC](https://discourse.glfw.org/t/i-get-a-link-error/1926/1 "2021-10-04T01:25:22Z")

</div>

Although it is a presentation code, I would like to know the cause of the error even if the link file is set.

##### Command

```auto
$ make
g++ obj/Ellipse.o obj/Line.o obj/Transform_2D.o obj/Circle.o obj/Rectangle.o obj/Triangle.o obj/Window.o obj/Camera.o obj/Main.o obj/Init.o obj/Resource.o obj/Text.o obj/Shader.o obj/Help.o obj/Point.o obj/Render.o obj/FrameWork.o obj/Simple_Draw.o -o GL -L/usr/local/lib -lGLU -lGL -lGLEW -lfreetype -lglfw3 -ldl
/usr/bin/ld: /usr/local/lib/libglfw3.a(posix_thread.c.o): undefined reference to symbol 'pthread_getspecific@@GLIBC_2.2.5'
/usr/bin/ld: /lib/x86_64-linux-gnu/libpthread.so.0: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
make: *** [Makefile:14: GL] エラー 1

```

##### Makefile

```auto
PRG :=GL
SRC_DIR :=source
OBJ_DIR :=obj
DEP_DIR :=obj
DEP :=$(wildcard $(DEP_DIR)/*.d)
SRC :=$(wildcard $(SRC_DIR)/*.cpp)
OBJ :=$(addprefix $(OBJ_DIR)/,$(patsubst %.cpp,%.o,$(notdir $(SRC))))
LDFLAGS :=`pkg-config --libs=opengl glew glfw3 freetype2`

$(PRG): $(OBJ)
    #$(CXX) $^ -l ncurses -o $@
	$(CXX) $^ -o $@ -L/usr/local/lib -lGLU -lGL -lGLEW -lfreetype -lglfw3 -ldl

$(OBJ_DIR)/%.o: source/%.cpp
	#$(CXX) -std=c++2a -I/usr/local/include/freetype2 -I/usr/include/libpng16 -I/usr/local/include -c -MMD -MP $< -o $@

	$(CXX) -std=c++2a -c -MMD -MP $< -o $@
	-include $(DEP)
	

clean:
	rm -f ./$(OBJ_DIR)/*.o *.out ./$(OBJ_DIR)/*.d *.a $(PRG)

```

---

<div class="post-metadata">

**Author:** ![mmozeiko](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.glfw.org/mmozeiko/32/29_2.png) [@mmozeiko](https://discourse.glfw.org/u/mmozeiko)\
**Post date:** [October 4, 2021, 2:05am UTC](https://discourse.glfw.org/t/i-get-a-link-error/1926/2 "2021-10-04T02:05:38Z")

</div>

Add `-lpthread` argument to your LDFLAGS. Typically when pthreads is used in code, you need to tell gcc to link explicitly to threads library.
