Can someone give me a simple step-by-step on how to set up and compile a simple "Hello World!" program on CLion using OpenGl/SDL/Freeglut . I see a lot of tutorials on Visual Studio, but CLion uses CMake so it's a lot different.


1 Answer 1


Use a CMakeLists.txt file. It would look something like this.

cmake_minimum_required(VERSION 3.3)


set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -pthread -fpermissive")

find_package (PkgConfig REQUIRED)
find_package (OpenGL REQUIRED)
find_package (GLUT REQUIRED)

include_directories(${OPENGL_INCLUDE_DIR}  ${GLUT_INCLUDE_DIRS})


add_executable(main.cpp ${SOURCE_FILES})

target_link_libraries (main.cpp ${OPENGL_LIBRARIES} ${GLUT_LIBRARIES} GL m dl Xinerama Xrandr Xi Xcursor X11 Xxf86vm pthread)

I copied this from a test project that I have. It works on Linux and Windows both. It is stripped down to only what is necessary.

This is where I learned https://cmake.org/cmake-tutorial/

  • \$\begingroup\$ Are OPENGL_INCLUDE_DIR and GLUT_INCLUDE_DIRS automatically set, or are they placeholders for the actual include directories? \$\endgroup\$
    – anon
    Commented Mar 8, 2018 at 5:45

Not the answer you're looking for? Browse other questions tagged .