CentOS 7 安装MuPDF(安装高版本gcc(11.2.1),安装opengl)

CentOS 7 安装MuPDF(安装高版本gcc(11.2.1),安装opengl)

MuPDF源码地址MuPDF

1.安装总结

#gcc
$sudo yum -y install centos-release-scl
$sudo yum -y install devtoolset-11-gcc devtoolset-11-gcc-c++ devtoolset-11-binutils
#opengl
$sudo yum list mesa*
$sudo yum install -y mesa*
$sudo yum install -y freeglut*
$sudo yum install -y *glew* 

$sudo yum install -y libXi-devel.x86_64
$sudo yum install -y libXrandr-devel.x86_64

$wget https://mupdf.com/downloads/archive/mupdf-1.19.0-source.tar.gz
$tar -zxvf mupdf-1.19.0-source.tar.gz
$cd mupdf-1.19.0-source
$scl enable devtoolset-11 bash
$make && make install
$mutool -v

2.编译MuPDF

2.1报错

g++: 错误:unrecognized command line option ‘-std=c++17’
make: *** [build/release/source/fitz/tessocr.o] 错误 1

出现这个编译错误的原因在g++ gcc 版本过低不支持C++17

2.2解决办法 使用centos-release-scl安装高版本gcc参考连接

$sudo yum install gcc -y		#默认安装旧版本4.85
$sudo yum -y install centos-release-scl	#安装centos-release-scl
$sudo yum list all --enablerepo='centos-sclo-rh'		#列出scl有哪些源可以使用
$sudo yum list all --enablerepo='centos-sclo-rh'|grep gcc		# 查看scl中gcc版本

devtoolset-10-gcc.x86_64                   10.2.1-11.2.el7        centos-sclo-rh
devtoolset-10-gcc-c++.x86_64               10.2.1-11.2.el7        centos-sclo-rh
devtoolset-10-gcc-gdb-plugin.x86_64        10.2.1-11.2.el7        centos-sclo-rh
devtoolset-10-gcc-gfortran.x86_64          10.2.1-11.2.el7        centos-sclo-rh
devtoolset-10-gcc-plugin-devel.x86_64      10.2.1-11.2.el7        centos-sclo-rh
devtoolset-10-libgccjit.x86_64             10.2.1-11.2.el7        centos-sclo-rh
devtoolset-10-libgccjit-devel.x86_64       10.2.1-11.2.el7        centos-sclo-rh
devtoolset-10-libgccjit-docs.x86_64        10.2.1-11.2.el7        centos-sclo-rh
devtoolset-11-annobin-plugin-gcc.x86_64    9.82-1.el7.1           centos-sclo-rh
devtoolset-11-gcc.x86_64                   11.2.1-1.2.el7         centos-sclo-rh
devtoolset-11-gcc-c++.x86_64               11.2.1-1.2.el7         centos-sclo-rh
devtoolset-11-gcc-gdb-plugin.x86_64        11.2.1-1.2.el7         centos-sclo-rh
devtoolset-11-gcc-gfortran.x86_64          11.2.1-1.2.el7         centos-sclo-rh
devtoolset-11-gcc-plugin-devel.x86_64      11.2.1-1.2.el7         centos-sclo-rh
devtoolset-11-libgccjit.x86_64             11.2.1-1.2.el7         centos-sclo-rh
devtoolset-11-libgccjit-devel.x86_64       11.2.1-1.2.el7         centos-sclo-rh
devtoolset-11-libgccjit-docs.x86_64        11.2.1-1.2.el7         centos-sclo-rh

$sudo yum -y install devtoolset-11-gcc devtoolset-11-gcc-c++ devtoolset-11-binutils  #安装新版本
$scl enable devtoolset-11 bash      #临时切换,退出服务器恢复
$echo "source /opt/rh/devtoolset-11/enable" >>/etc/profile  #永久切换

3.继续编译

3.1报错

In file included from thirdparty/freeglut/include/GL/freeglut.h:17,
                 from platform/gl/gl-app.h:36,
                 from platform/gl/gl-annotate.c:23:
thirdparty/freeglut/include/GL/freeglut_std.h:143:13: fatal error: GL/gl.h: 没有那个文件或目录
  143 | #   include <GL/gl.h>
      |             ^~~~~~~~~
compilation terminated.
make: *** [build/release/platform/gl/gl-annotate.o] 错误 1

错误原因:系统里面缺少OpenGl库

3.2 解决办法 配置OpenGL开发环境(也可以只安装opengl库)

$sudo yum list mesa*	#三维计算机图形库,以开源形式实现了OpenGL的应用程序接口。
$sudo yum install -y mesa*
$sudo yum install -y freeglut*
$sudo yum install -y *glew* 

相关知识点Mesa 到底是什么
测试程序main.c

#include <GL/gl.h>
#include <GL/glut.h>
#include <stdlib.h>

void init(void)
{
  glClearColor(0.0, 0.0, 0.0, 0.0);
  glMatrixMode(GL_PROJECTION);
  glOrtho(-5,5,-5,5,5,15);
  glMatrixMode(GL_MODELVIEW);
  gluLookAt(0,0,10,0,0,0,0,1,0);

  return;
}
void display(void)
{
  glClear(GL_COLOR_BUFFER_BIT);
  glColor3f(1.0, 0, 0);
  glutWireTeapot(3);
  glFlush();

  return;
}

int main(int argc, char* argv[])
{
  glutInit(&argc, argv);
  glutInitDisplayMode(GLUT_RGB|GLUT_SINGLE);
  glutInitWindowPosition(0,0);
  glutInitWindowSize(300, 300);
  glutCreateWindow("OpenGL 3D View");
  init();
  glutDisplayFunc(display);

  glutMainLoop();
  return 0;
}
#编译
gcc -lglut -lGLU -lGL -o main main.c
#运行
./main

在这里插入图片描述

4.继续编译

4.1报错

In file included from thirdparty/freeglut/src/fg_internal.h:192,
                 from thirdparty/freeglut/src/fg_callbacks.c:29:
thirdparty/freeglut/src/x11/fg_internal_x11.h:42:10: fatal error: X11/extensions/XInput.h: 没有那个文件或目录
   42 | #include <X11/extensions/XInput.h>
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
make: *** [build/release/thirdparty/freeglut/src/fg_callbacks.o] 错误 1

4.2解决办法

$sudo yum install -y libXi-devel.x86_64

5.继续编译

5.1报错

In file included from thirdparty/freeglut/src/fg_internal.h:192,
                 from thirdparty/freeglut/src/fg_callbacks.c:29:
thirdparty/freeglut/src/x11/fg_internal_x11.h:47:14: fatal error: X11/extensions/Xrandr.h: 没有那个文件或目录
   47 | #    include <X11/extensions/Xrandr.h>
      |              ^~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
make: *** [build/release/thirdparty/freeglut/src/fg_callbacks.o] 错误 1

5.2解决办法

$sudo yum install -y libXrandr-devel.x86_64

6.参考链接

centos7安装gcc新版本

事后发现一个已有总结的文章CentOS 安装 mutool mupdf-tools

  • 0
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值