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)
    project(world_0)

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

    find_package(GLFW3 REQUIRED)

    include_directories(F:/u_qt/libs/glfw/glfw-3.0.1/include)
    link_directories(F:/u_qt/libs/glfw/glfw-3.0.1/lib-mingw)

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

    I've added FindGLFW3.cmake from "FindGLFW3.make":https://raw.github.com/zero57/CMakeScripts/master/FindGLFW3.cmake
    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
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.