0
我試圖從http://www.glprogramming.com/red/chapter01.html構建hello.c示例(查找「示例1-2」)。OpenGL hello.c無法使用CMake構建
我的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的呼叫在產生所需的生成文件成功。但是當我撥打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
如何解決此問題?
感謝。那樣做了。你能解釋一下問題是什麼? – 2012-07-13 18:52:12
@AgnelKurian CMake變量區分大小寫(命令不是)。 [FindOpenGL'的文檔(http://www.cmake.org/cmake/help/v2.8.8/cmake.html#module:FindOpenGL)列出了它設置的變量。 – Fraser 2012-07-13 18:58:00