Nominate our 2022 Qt Champions!

Non Qt project (Cmake) - troubles with linking to library

  • Hi guys,

    I freshly installed Qt Creator with MinGW and Cmake. I'm trying to play with OpenGL.
    So far I got this code:

    @#include <GLFW/glfw3.h>

    int main()
    if (!glfwInit()) {
    return -1;

    return 0;


    My CMakeLists.txt is like this:

    @cmake_minimum_required(VERSION 2.8)

    aux_source_directory(. SRC_LIST)
    file(GLOB SRC_LIST *.cpp)

    find_package(GLFW3 REQUIRED)


    add_executable(${PROJECT_NAME} ${SRC_LIST})
    target_link_libraries(${PROJECT_NAME} glfw3)@

    I've added FindGLFW3.cmake from "FindGLFW3.make":
    But still got 'undefined reference' error.

    I will be glad to hear any feedback from you guys. Cheers.

  • Paste complete error message, please. Very often 'undefined reference' error is not connected with particular library (in this case OpenGL), but with some other not fulfilled dependencies.

Log in to reply