0

I'm trying to use OpenGL and GLUT in CLion. My CMakeLists.txt:

cmake_minimum_required(VERSION 3.14)
project(Graphos)

set(CMAKE_CXX_STANDARD 17)

find_library(GLUT REQUIRED)
find_library(OpenGL REQUIRED)

include_directories(.)

add_executable(
        Graphos
        AdjacencyList.h
        main.cpp
        Node.h
        UsefulFunctions.h
        Macros.h
        Coordinates.h
        GraphDrawer.h
)

When I run the project I get the following Linker Error:

Undefined symbols for architecture x86_64: "_glClearColor", referenced from: ...

that lists several gl and glut functions.

This is the OpenGL code that I've written:

GLvoid initGL() {
        glClearColor(0, 0, 0, 1);
        glMatrixMode(GL_PROJECTION);
        glLoadIdentity();
}

GLvoid initialize(int argc, char** argv) {
        glutInit(&argc, argv);
        glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_DEPTH);
        glutInitWindowSize(WINDOW_WIDTH, WINDOW_HEIGHT);
        glutInitWindowPosition(200,200);
        glutCreateWindow("Graphs");
        initGL();
}

Help me please.

1 Answer 1

1
cmake_minimum_required(VERSION 3.14)
project(Graphos)

set(CMAKE_CXX_STANDARD 17)

add_executable(
        Graphos
        AdjacencyList.h
        main.cpp
        Node.h
        UsefulFunctions.h
        Macros.h
        Coordinates.h
        GraphDrawer.h
)

find_package(OpenGL REQUIRED)
find_package(GLUT REQUIRED)

# Included these two lines:

include_directories(${OPENGL_INCLUDE_DIRS} ${GLUT_INCLUDE_DIRS})
target_link_libraries(Graphos ${OPENGL_LIBRARIES} ${GLUT_LIBRARY})
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.