OpenGL的hello.c的失败使用CMake的构建 [英] OpenGL hello.c fails to build using CMake

查看:458
本文介绍了OpenGL的hello.c的失败使用CMake的构建的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图建立从 http://www.glprogramming.com的例子的hello.c /red/chapter01.html (寻找例1-2)。

I am trying to build the hello.c example from http://www.glprogramming.com/red/chapter01.html (look for "Example 1-2").

我的CMakeLists.txt如下:

My CMakeLists.txt is as follows:

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文件。但是,当我打电话制作,我遇到以下内容:

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

我该如何解决这个问题?

How do I fix this?

推荐答案

尝试更改

target_link_libraries (glutex ${OpenGL_LIBRARIES})

target_link_libraries (glutex ${OPENGL_LIBRARIES})

这篇关于OpenGL的hello.c的失败使用CMake的构建的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆