#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 -v2.编译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
| ^~~~~~~~~
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#include #include 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 #运行 ./main4.继续编译 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
| ^~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
make: *** [build/release/thirdparty/freeglut/src/fg_callbacks.o] 错误 1
4.2解决办法
$sudo yum install -y libXi-devel.x86_645.继续编译 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
| ^~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
make: *** [build/release/thirdparty/freeglut/src/fg_callbacks.o] 错误 1
5.2解决办法
$sudo yum install -y libXrandr-devel.x86_646.参考链接
centos7安装gcc新版本
事后发现一个已有总结的文章CentOS 安装 mutool mupdf-tools


