Hi everyone,
I try to get a simple example to build using cmake and mingw, but it seems that I can’t get nothing working…
I’ve dowloaded the glfw-3.2.1 prebuilt windows binaries and unzipped it.
Here is my CMakeLists.txt :
cmake_minimum_required(VERSION 3.0.0)
project(OpenGl_Base VERSION 0.1.0)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_SOURCE_DIR}/cmake/modules/")
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
find_package(glfw3 3.2 REQUIRED)
find_package(OpenGL REQUIRED)
add_executable(OpenGl_Base main.cpp)
target_include_directories(OpenGl_Base PUBLIC ${OPENGL_INCLUDE_DIR} ${GLFW3_INCLUDE_DIR})
target_link_libraries(OpenGl_Base ${GLFW3_LIBRARY} ${OPENGL_gl_LIBRARY})
Note that I had to add a module for find_package to work with glfw which I copied from here which I edited to add my own path for glfw.
the error I get with this config is :
[build] Starting build
[proc] Executing command: E:\Programs\CMake\bin\cmake.EXE --build e:/Projets/OpenglBase/build --config Debug --target OpenGl_Base -- -j 6
[build] Scanning dependencies of target OpenGl_Base
[build] [ 50%] Building CXX object CMakeFiles/OpenGl_Base.dir/main.cpp.obj
[build] [100%] Linking CXX executable OpenGl_Base.exe
[build] CMakeFiles/OpenGl_Base.dir/objects.a(main.cpp.obj): In function `main':
[build] E:/Projets/OpenglBase/main.cpp:8: undefined reference to `glfwInit'
[build] E:/Projets/OpenglBase/main.cpp:12: undefined reference to `glfwCreateWindow'
[build] E:/Projets/OpenglBase/main.cpp:15: undefined reference to `glfwTerminate'
[build] E:/Projets/OpenglBase/main.cpp:20: undefined reference to `glfwMakeContextCurrent'
[build] E:/Projets/OpenglBase/main.cpp:23: undefined reference to `glfwWindowShouldClose'
[build] E:/Projets/OpenglBase/main.cpp:29: undefined reference to `glfwSwapBuffers'
[build] E:/Projets/OpenglBase/main.cpp:32: undefined reference to `glfwPollEvents'
[build] E:/Projets/OpenglBase/main.cpp:35: undefined reference to `glfwTerminate'
[build] collect2.exe: error: ld returned 1 exit status
[build] CMakeFiles/OpenGl_Base.dir/build.make:86: recipe for target 'OpenGl_Base.exe' failed
[build] make.exe[3]: *** [OpenGl_Base.exe] Error 1
[build] CMakeFiles/Makefile2:72: recipe for target 'CMakeFiles/OpenGl_Base.dir/all' failed
[build] make.exe[2]: *** [CMakeFiles/OpenGl_Base.dir/all] Error 2
[build] CMakeFiles/Makefile2:84: recipe for target 'CMakeFiles/OpenGl_Base.dir/rule' failed
[build] make.exe[1]: *** [CMakeFiles/OpenGl_Base.dir/rule] Error 2
[build] Makefile:118: recipe for target 'OpenGl_Base' failed
[build] make.exe: *** [OpenGl_Base] Error 2
[build] Build finished with exit code 2
Thanks for your time