I wrote c++ project in which I am using OpenGL and Glut library.
When I compile it from command line everything works fine. Here is sample.
g++ -o prog source.cpp -lGL -lGLU -lglut --std=c++11 -L /usr/lib/nvidia-331/
But when I want to use CMake in QtCreator:
project(proj)
cmake_minimum_required(VERSION 2.8)
aux_source_directory(. SRC_LIST)
add_executable(${PROJECT_NAME} ${SRC_LIST})
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -lGL -lGLU -lglut -L /usr/lib/nvidia-331/")
I recieve msg: error: undefined reference to `glColor3f' and so on.
Can anybody help me?
project(proj)
cmake_minimum_required(VERSION 2.8)
find_package(OpenGL)
find_package(GLUT)
aux_source_directory(. SRC_LIST)
add_executable(${PROJECT_NAME} ${SRC_LIST})
target_link_libraries(
${PROJECT_NAME}
${OPENGL_gl_LIBRARY}
${GLUT_LIBRARIES} )
Note: You should not use the project name for the executable
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With