CMake Target Link Library "Could NOT find GLUT (missing: GLUT_glut_LIBRARY)"
Do not hardcode paths into your CMakeLists! It defeats the whole purpose of CMake as a portable build system.
If you want to override the values obtained by CMake's find script, provide the values via the command line or one of the cmake UIs (ccmake
or cmake-gui
).
Also be sure to check at least the documentation for all find modules that you use and if that still leaves questions open, go directly to the source code. For example, the GLUT_LIB_DIR
variable that you use does not exist. Also, notice that the find script uses the GLUT_ROOT_PATH
variable as a hint on the location of your local GLUT installation on Windows.
Finally, make sure that GLUT is actually installed on your machine. Visual C++ does not ship with GLUT by default, so you may have to download and build it yourself first.
Comments
-
Vyper almost 2 years
Following is my cmake file on which I get the error "Could NOT find GLUT (missing: GLUT_glut_LIBRARY)". I guess there is problem with my target link library. What exactly am I doing wrong ?
cmake_minimum_required(VERSION 2.6) SET(MY_PROJECT_NAME Test_1) SET(MY_SOURCE_FILES Task_1.cpp) SET(GLUT_INCLUDE_DIR C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\GL) SET(GLUT_LIBRARY C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\lib\glut32.lib) project(${MY_PROJECT_NAME}) # required libraries find_package(OpenGL REQUIRED) find_package(GLUT REQUIRED) # include directories include_directories( ${GLUT_LIB_DIR} ${OPENGL_INCLUDE_DIR} ${GLUT_INCLUDE_DIR} ) # source code files (sources *and* headers ) add_executable(${MY_PROJECT_NAME} ${MY_SOURCE_FILES} ) # link against these libraries target_link_libraries(${MY_PROJECT_NAME} ${GLUT_LIBRARY} ${OPENGL_LIBRARY} )