0

everybody. I have to compile my OpenGL program but occurs that couldn't find OpenGL, the following is the error hint.

Error:Could NOT find GLUT (missing: GLUT_glut_LIBRARY GLUT_INCLUDE_DIR)

However, I tried plenty of ways to solve without taking effort. This is my CMakeList.txt.

cmake_minimum_required(VERSION 3.6)
project(master_para)

#########################################################
# FIND GLUT
#########################################################
find_package(GLUT REQUIRED)
include_directories(${GLUT_INCLUDE_DIRS})
link_directories(${GLUT_LIBRARY_DIRS})
add_definitions(${GLUT_DEFINITIONS})
if(NOT GLUT_FOUND)
    message(ERROR " GLUT not found!")
endif(NOT GLUT_FOUND)
#########################################################
# FIND OPENGL
#########################################################
find_package(OpenGL REQUIRED)
include_directories(${OpenGL_INCLUDE_DIRS})
link_directories(${OpenGL_LIBRARY_DIRS})
add_definitions(${OpenGL_DEFINITIONS})
if(NOT OPENGL_FOUND)
    message(ERROR " OPENGL not found!")
endif(NOT OPENGL_FOUND)

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3 -Wall -std=c++11")

set(SOURCE_FILES
    gnode.h
    gstack.h
    lsys.h
    main.cpp
    main.h)

add_executable(para ${SOURCE_FILES})

target_link_libraries(para ${GLUT_LIBRARY} ${OPENGL_LIBRARY})

I confirm that have installed package mesa-common-dev, mesa-utils-extra, libgl1-mesa-dev but still doesn't work. Could anyone help me? Thanks in advance.

After temptations, I have successfully compiled with the following code, however, with another method. I'm still stuck in how the above way cannot take effort...

cmake_minimum_required(VERSION 3.6)
project(master_para)

#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3 -Wall -std=c++11")

set(SOURCE_FILES
    gnode.h
    gstack.h
    lsys.h
    main.cpp
    main.h)

add_executable(para ${SOURCE_FILES})

#find_package(OpenGL REQUIRED)
#find_package(GLUT REQUIRED)
#include_directories( ${OPENGL_INCLUDE_DIRS}  ${GLUT_INCLUDE_DIRS} )

#target_link_libraries(para ${OPENGL_LIBRARIES} ${GLUT_LIBRARY} )
target_link_libraries(para GL GLU glut)
Jian Cao
  • 21
  • 1
  • 7
  • I tried *make*, however, can compile code normally, without any error. The problem seems occurs with cmake. – Jian Cao Aug 25 '16 at 12:04
  • Looks like you didn't install glut. It does not come with mesa packages. – Sergey Aug 25 '16 at 12:09
  • 1
    I've installed freeglut3 freeglut3-dev libglew1.5 libglew1.5-dev libglu1-mesa libglu1-mesa-dev libgl1-mesa-glx libgl1-mesa-dev, still take no effort.. – Jian Cao Aug 25 '16 at 12:37
  • BTW: Which linux system you're using? If Ubuntu, maybe try to install also `libxrandr-dev` – devopsfun Aug 25 '16 at 14:47
  • Sure, I'm using Ubuntu16.04, with libxrandr-dev installed. – Jian Cao Aug 25 '16 at 16:52
  • Does this question help? http://stackoverflow.com/q/39126648/2799037 – usr1234567 Aug 25 '16 at 17:38
  • Thanks, but still doesn't work. – Jian Cao Aug 26 '16 at 08:19
  • Then you have to clarify your question, add error messages and so on. – usr1234567 Aug 26 '16 at 15:14
  • So, you have library `glut` installed into default (for linker) directory, but CMake doesn't check this directory for some reason when search the library. What **exact path** to the `glut` library on your system (use `ldd `)? If `ldd` refers to `glut.so.` file, check that corresponded file `glut.so` exists in the same directory. – Tsyvarev Aug 28 '16 at 16:47
  • 1
    Did you solve your issue? Installing `freeglut3-dev` solved the error for me but I still have another error: https://stackoverflow.com/questions/36297775/cant-use-assimp-library#comment91080607_36495277 – baptx Aug 28 '18 at 19:37

0 Answers0