I'm trying to get OpenGL to work in CLion, downloaded the bin/include/library files from freeglut and copied them to minGW. They are there, and CLion is using that minGW folder when compiling, however when it tries to compile the test code that freeglut provides, it returns with "fatal error: GL/glut.h: No such file or directory #include <GL/glut.h>
"
I have already tried different versions of CMakeLists, all of them return with the same issue. If I copy the GL folder next to the project, I get loads of undefined references.
After trying this CMakeList, I get the same error. (from Running Opengl program with CLion IDE)
cmake_minimum_required(VERSION 3.14)
project(gltest)
set(CMAKE_CXX_STANDARD 14)
set (CMAKE_CXX_FLAGS "-lglut")
set (CMAKE_CXX_FLAGS "-lGL")
set (CMAKE_CXX_FLAGS "-lGLU")
include_directories(GL/)
add_executable(gltest Callbacks.c HelloGLUT.c)
target_link_libraries(gltest -lglut -lGL -lGLU)
UPDATE
After using a new CMakeList(as suggested in the comments, im more than grateful to you wonderful people here) I get some new errors, but CLion seems to be able to reach the GL libraries now.
The CMakeList:
cmake_minimum_required(VERSION 3.14)
project(gltest)
set(SOURCE_FILES Callbacks.c HelloGLUT.c)
set(OPENGL_INCLUDE_DIR C:/minGW/mingw64/include)
set(OPENGL_LIBRARY C:/minGW/mingw64/lib)
find_package(OPENGL REQUIRED)
add_executable(gltest ${SOURCE_FILES})
include_directories(${OPENGL_INCLUDE_DIR})
target_link_libraries(gltest ${OPENGL_LIBRARY} )
Errors:
CMakeFiles\gltest.dir/objects.a(Callbacks.c.obj): In function "glutInit_ATEXIT_HACK':
C:/minGW/mingw64/include/GL/freeglut_std.h:637: undefined reference to "__imp___glutInitWithExit"
CMakeFiles\gltest.dir/objects.a(Callbacks.c.obj): In function "glutCreateWindow_ATEXIT_HACK":
And several more undefined references in the same manner to various "__imp___glut" functions. Any ideas?
If I use target_link_libraries(gltest ${OPENGL_LIBRARY} glut GL GLU)
I get
"C:/minGW/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lglut " , same for lGL and lGLU