Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/opengl/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
OpenGL hello.c无法使用CMake构建_Opengl_Build_Makefile_Cmake_Glut - Fatal编程技术网

OpenGL hello.c无法使用CMake构建

OpenGL hello.c无法使用CMake构建,opengl,build,makefile,cmake,glut,Opengl,Build,Makefile,Cmake,Glut,我正试图从中构建hello.c示例(参见“示例1-2”) 我的CMakeLists.txt如下: cmake_minimum_required (VERSION 2.8) project (GLUTEX) find_package(OpenGL REQUIRED) find_package(GLUT REQUIRED) include_directories(${GLUT_INCLUDE_DIRS}) include_directories(${OpenGL_INCLUDE_DIRS}) a

我正试图从中构建hello.c示例(参见“示例1-2”)

我的CMakeLists.txt如下:

cmake_minimum_required (VERSION 2.8)
project (GLUTEX)

find_package(OpenGL REQUIRED)
find_package(GLUT REQUIRED)
include_directories(${GLUT_INCLUDE_DIRS})
include_directories(${OpenGL_INCLUDE_DIRS})

add_executable (glutex glutex.c)
target_link_libraries (glutex ${OpenGL_LIBRARIES})
target_link_libraries (glutex ${GLUT_LIBRARIES})
CMake调用成功生成所需的Makefile。但是当我调用
make
时,我会遇到以下情况:

Scanning dependencies of target glutex
[100%] Building C object CMakeFiles/glutex.dir/glutex.c.o
Linking C executable glutex
/usr/bin/ld: CMakeFiles/glutex.dir/glutex.c.o: undefined reference to symbol 'glOrtho'
/usr/bin/ld: note: 'glOrtho' is defined in DSO /usr/lib64/libGL.so.1 so try adding it to the linker command line
/usr/lib64/libGL.so.1: could not read symbols: Invalid operation
collect2: ld returned 1 exit status
make[2]: *** [glutex] Error 1
make[1]: *** [CMakeFiles/glutex.dir/all] Error 2
make: *** [all] Error 2
如何修复此问题?

尝试更改

target_link_libraries (glutex ${OpenGL_LIBRARIES})


谢谢成功了。您能解释一下问题是什么吗?@AgnelKurian CMake变量区分大小写(命令不区分大小写)。列出了它设置的变量。
target_link_libraries (glutex ${OPENGL_LIBRARIES})