0

我正在尝试从http://www.glprogramming.com/red/chapter01.html构建 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

我该如何解决?

4

1 回答 1

1

尝试改变

target_link_libraries (glutex ${OpenGL_LIBRARIES})

target_link_libraries (glutex ${OPENGL_LIBRARIES})
于 2012-07-13T18:25:16.707 回答