error: GL/gl.h: No such file or directory

1 介绍

环境:ubuntu系统 + Qt 5.9
Qt开发用到 OpenGL,然后程序编译时报错,error: GL/gl.h: No such file or directory,显示找不到该文件。

2 分析

  • GL/gl.h 是ubuntu中库文件,需要安装。
  • GL/gl.h和x11相关,即 sudo apt-get install build-essential
  • apt-get和aptitude
    ubuntu安装软件时出现The following packages have unmet dependencies,有依赖关系。即安装opengl的依赖,显示底层的库版本过低。ubuntu16,多见这问题,底层库版本有冲突,可以用aptitude代替apt-get。
    aptitude工具能处理版本冲突的问题。
  • ubuntu16源的问题
    配置阿里的源,Ubuntu下安装APP遇到依赖模块版本不对,一般是16.04版本,给配置了其它版本的源导致。

3 操作步骤

3.1 切换apt-get源

切换到阿里的源

sudo vim /etc/apt/sources.list
# deb cdrom:[Ubuntu 16.04 LTS _Xenial Xerus_ - Release amd64 (20160420.1)]/ xenial main restricted
deb-src http://archive.ubuntu.com/ubuntu xenial main restricted #Added by software-properties
deb http://mirrors.aliyun.com/ubuntu/ xenial main restricted
deb-src http://mirrors.aliyun.com/ubuntu/ xenial main restricted multiverse universe #Added by software-properties
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted multiverse universe #Added by software-properties
deb http://mirrors.aliyun.com/ubuntu/ xenial universe
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates universe
deb http://mirrors.aliyun.com/ubuntu/ xenial multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse #Added by software-properties
deb http://archive.canonical.com/ubuntu xenial partner
deb-src http://archive.canonical.com/ubuntu xenial partner
deb http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted multiverse universe #Added by software-properties
deb http://mirrors.aliyun.com/ubuntu/ xenial-security universe
deb http://mirrors.aliyun.com/ubuntu/ xenial-security multiverse

3.2 安装

udo apt-get install build-essential
sudo apt-get install build-essential libgl1-mesa-dev
sudo apt-get install libglew-dev libsdl2-dev libsdl2-image-dev libglm-dev libfreetype6-dev
sudo apt-get install libglfw3-dev libglfw3

3.3 运行

上述操作完,运行就行。

参考

1、OpenGL Programming/Installation/Linux
2、Ubuntu 16.04 安装OpenGL & 运行第一个demo–阿里源
3、Ubuntu16.04安装opengl

展开阅读全文

没有更多推荐了,返回首页

©️2019 CSDN 皮肤主题: 技术黑板 设计师: CSDN官方博客
应支付0元
点击重新获取
扫码支付

支付成功即可阅读