# Basic Program Undefined Reference to symbo 'dlclose@@GLIBC

**URL:** <https://discourse.glfw.org/t/basic-program-undefined-reference-to-symbo-dlclose-glibc/1393>\
**Category:** support\
**Created:** [August 8, 2019, 2:38am UTC](https://discourse.glfw.org/t/basic-program-undefined-reference-to-symbo-dlclose-glibc/1393 "2019-08-08T02:38:22Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nirodha](https://avatars.discourse-cdn.com/v4/letter/n/ed655f/32.png) [@Nirodha](https://discourse.glfw.org/u/Nirodha)\
**Post date:** [August 8, 2019, 2:38am UTC](https://discourse.glfw.org/t/basic-program-undefined-reference-to-symbo-dlclose-glibc/1393/1 "2019-08-08T02:38:22Z")

</div>

Hello,

I’m trying to get up and running with GLFW and haven’t had much luck. I’m on Linux Mint using GCC 7.3.0.

I cloned the GLFW repo, built the libraries, and ran make install.

Now I have a simple CMakeLists.txt:

```
cmake_minimum_required(VERSION 3.5)

project(hello-glfw)

set(GLFW_DIR /usr/local/lib/cmake/glfw3)

add_executable(hello-glfw hello-glfw.cpp)

find_package(glfw3 REQUIRED)

find_package(OpenGL REQUIRED)

target_link_libraries(hello-glfw OpenGL glfw3)

```

I can run CMake from here, no problems.  
My source code (hello-glfw.cpp) is just copy-pasted from one of the GLFW guides):

```
#include <GL/glut.h>
#include <GLFW/glfw3.h>

int main(void)
{
    GLFWwindow* window;

    /* Initialize the library */
    if (!glfwInit())
        return -1;

    /* Create a windowed mode window and its OpenGL context */
    window = glfwCreateWindow(640, 480, "Hello World", NULL, NULL);
    if (!window)
    {
        glfwTerminate();
        return -1;
    }

    /* Make the window's context current */
    glfwMakeContextCurrent(window);

    /* Loop until the user closes the window */
    while (!glfwWindowShouldClose(window))
    {
        /* Render here */
        glClear(GL_COLOR_BUFFER_BIT);

        /* Swap front and back buffers */
        glfwSwapBuffers(window);

        /* Poll for and process events */
        glfwPollEvents();
    }

    glfwTerminate();
    return 0;
}

```

The above code gives me an error: undefined reference to symbol ‘dlclose@GLIBC\_2.2.5’.  
A few minutes of google searching told me to include the ‘dl’ library. I updated my target\_link\_libraries to:

```
target_link_libraries(hello-glfw dl OpenGL glfw3)

```

But I’m still getting the error.

Any thoughts?

Thanks in advance!

---

<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:** [August 8, 2019, 9:34am UTC](https://discourse.glfw.org/t/basic-program-undefined-reference-to-symbo-dlclose-glibc/1393/2 "2019-08-08T09:34:03Z")

</div>

There’s a section on [compiling with Cmake and installed GLFW binaries in the documentation](https://www.glfw.org/docs/latest/build_guide.html#build_link_cmake_package).

From what I can see the only error you have is that you should link to `glfw` rather than `glfw3`. Try this and if you still have issues come back to this thread.

---

<div class="post-metadata">

**Author:** ![ThomasL81](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.glfw.org/thomasl81/32/256_2.png) [@ThomasL81](https://discourse.glfw.org/u/ThomasL81)\
**Post date:** [August 12, 2019, 5:17am UTC](https://discourse.glfw.org/t/basic-program-undefined-reference-to-symbo-dlclose-glibc/1393/3 "2019-08-12T05:17:15Z")

</div>

I know you state that you added the dl lib in cmake, can you explicitly try this variable? It might include more dependencies:  
`target_link_libraries(hello-glfw ${CMAKE_DL_LIBS} OpenGL glfw3)`
