centos6.5 编译pdf2htmlEx(一)

http://blog.csdn.net/haha4799/article/details/50725100

1、升级gcc

wget http://ftp.gnu.org/gnu/gcc/gcc-6.1.0/gcc-6.1.0.tar.bz2 tar -jxvf gcc-6.1.0.tar.bz2 cd gcc-6.1.0 ./contrib/download_prerequisites  mkdir gcc-build-6.1.0 cd gcc-build-6.1.0 ../configure -enable-checking=release -enable-languages=c,c++ -disable-multilib make -j4 make install https://www.cnblogs.com/lzpong/p/5755678.html

注意:

configure: error: Building GCC requires GMP 4.2+, MPFR 2.4.0+ and MPC 0.8.0+. Try the --with-gmp, --with-mpfr and/or --with-mpc options to specify their locations. Source code for these libraries can be found at their respective hosting sites as well as at ftp://gcc.gnu.org/pub/gcc/infrastructure/. See also http://gcc.gnu.org/install/prerequisites.html for additional info. If you obtained GMP, MPFR and/or MPC from a vendor distribution package, make sure that you have installed both the libraries and the header files. They may be located in separate packages.

解决办法:

sudo yum install gmp gmp-devel mpfr mpfr-devel libmpc libmpc-devel 先执行第一步,如果第一步有什么问题,再继续后面的操作

  1. sudo yum -y install glibc-devel.i686 glibc-devel
  2. wget http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm rpm -ivh epel-release-6-8.noarch.rpm yum install XXX 2. yum -y install gmp 3. yum -y install mpfr
2、安装pkg-config-0.28

yum install zlib-devel.x86_64 glib2-devel.x86_64 -y wget https://pkg-config.freedesktop.org/releases/pkg-config-0.28.tar.gz tar -xzvf pkg-config-0.28.tar.gz cd pkg-config-0.28 ./configure make && make install mv /usr/bin/pkg-config /usr/bin/pkg-configbak ln -s /usr/local/bin/pkg-config /usr/bin/pkg-config pkg-config -version


3、安装autoconf-2.69

wget http://ftp.gnu.org/gnu/autoconf/autoconf-2.69.tar.gz tar -zxvf autoconf-2.69.tar.gz cd autoconf-2.69 ./configure -prefix=/usr make && make install


4、 环境变量

export PKG_CONFIG_PATH=/usr/lib64/pkgconfig:/usr/lib/pkgconfig export LD_LIBRARY_PATH=/usr/lib64:/usr/lib export png_REQUIRES="libpng"


5、安装freetype-2.5.2

wget https://download.savannah.gnu.org/releases/freetype/freetype-2.5.2.tar.gz yum install libtool-ltdl-devel.x86_64 libtool patch gettext.x86_64fontconfig fontconfig-devel poppler-glib-devel.x86_64 libpng-devel.x86_64 -y tar -zxvf freetype-2.5.2.tar.gz cd freetype-2.5.2 ./configure -prefix=/usr make && make install


6、安装cairo-1.12.2

解决办法 mkdir -p /usr/local/freetype//include/freetype2/freetype/internal

  • a. yum install libspectre libspectre-devel

注意:

cairo-1.12.2 make && make install 报错 /opt/office/dir/cairo-1.12.2/src/.libs/libcairo.so: undefined reference to png_create_read_struct' /opt/office/dir/cairo-1.12.2/src/.libs/libcairo.so: undefined reference to png_set_write_user_transform_fn' /opt/office/dir/cairo-1.12.2/src/.libs/libcairo.so: undefined reference to png_set_bKGD' /opt/office/dir/cairo-1.12.2/src/.libs/libcairo.so: undefined reference to png_get_valid'

解决方法

sudo yum install -y cmake gcc gnu-getopt libpng-devel fontforge-devel cairo-devel poppler-devel libspiro-devel freetype-devel poppler-data libjpeg-turbo-devel git make gcc-c++ pango-devel

sudo yum install -y libjpeg-turbo.x86_64 libjpeg-turbo-devel libjpeg-turbo-devel.x86_64 libtiff.x86_64 libtiff-devel openjpeg-devel.x86_64 openjpeg giflibgiflib-devel libxml2.x86_64 libxml2-devel libspiro.x86_64 libspiro-devel libuninameslist-devel.x86_64

重新编译一遍,./configure 记得不要有prefix make && make install 如果还不行,就重新导出一份其他系统安装好的最新的/usr/local/lib/pkgconfig 文件夹到本系统中

7、安装fontforge
  • a). yum install libjpeg-turbo.x86_64libjpeg-turbo-devel libjpeg-turbo-devel.x86_64 libtiff.x86_64 libtiff-devel openjpeg-devel.x86_64 openjpeg giflibgiflib-devel libxml2.x86_64 libxml2-devel libspiro.x86_64 libspiro-devel libuninameslist-devel.x86_64 -y
  • b). 安装libunicodenames xz -d libunicodenames-1.0.1.tar.xz tar xf libunicodenames-1.0.1.tar cd libunicodenames-1.0.1 ./configure -prefix=/usr make && make install
  • c). 安装readline-6.3
  • d). fontforge unzip fontforge-pdf2htmlEX.zip cd fontforge-pdf2htmlEX 需要切换分支到pdf2html ./autogen.sh ./configure -prefix=/usr -without-libzmq -without-x-without-iconv -disable-python-scripting -disable-python-extension make && make install

注意:如果报错,执行下面的代码

./configure -prefix=/usr -with-iconv=/usr/local/libiconv -without-libzmq -without-x-without-iconv -disable-python-scripting -disable-python-extension

8、安装poppler

cp /usr/lib/pkgconfig/cairo*.pc /usr/lib64/pkgconfig cp /usr/lib/libcairo* /usr/lib64 xz -d poppler-0.41.0.tar.xz tar xf poppler-0.41.0.tar cd poppler-0.41.0 ./configure --prefix=/usr --enable-xpdf-headers make && make install cp /usr/lib/pkgconfig/poppler*.pc /usr/lib64/pkgconfig cp /usr/lib/libpoppler*.so /usr/lib64

9.安装pdf2html

cmake . && make && sudo make install

问题1:

Variable 'top_build_prefix' not defined in '/usr/lib/pkgconfig/libfontforge.pc' Variable 'top_build_prefix' not defined in '/usr/lib/pkgconfig/libfontforge.pc' Variable 'top_build_prefix' not defined in '/usr/lib/pkgconfig/libfontforge.pc' Variable 'top_build_prefix' not defined in '/usr/lib/pkgconfig/libfontforge.pc' Variable 'top_build_prefix' not defined in '/usr/lib/pkgconfig/libfontforge.pc' Variable 'top_build_prefix' not defined in '/usr/lib/pkgconfig/libfontforge.pc' Variable 'top_build_prefix' not defined in '/usr/lib/pkgconfig/libfontforge.pc'

解决方法:

export CC=/usr/local/bin/gcc export CXX=/usr/local/bin/g++

问题2:

your compiler does not support C++0x/C++11, please update it 升级gcc到4.7以上,有文档可以升级到4.8

问题:

CMakeFiles/pdf2htmlEX.dir/3rdparty/poppler/git/CairoOutputDev.cc.o: In function CairoOutputDev::patchMeshShadedFill(GfxState*, GfxPatchMeshShading*)': CairoOutputDev.cc:(.text+0x1149): undefined reference to cairo_pattern_create_mesh' CairoOutputDev.cc:(.text+0x1195): undefined reference to `cairo_mesh_pattern_begin_patch'

解决办法

重新安装cairo

问题3 pdf2htmlEX

Trying to locate cairo-svg... CMake Error at CMakeLists.txt:47 (message): Error: no SVG support found in Cairo -- Configuring incomplete, errors occurred! See also "/home/zzq/app/pdf2htmlEX-master/CMakeFiles/CMakeOutput.log".

解决方法

此处报错,需要导入环境再执行,如果不行重新安装cairo [root@weekend110 pdf2htmlEX-master]# yum install poppler* -y [root@weekend110 pdf2htmlEX-master]# export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig

问题4:我在编译pdf2htmlex的时候遇到了下面的错误

Linking CXX executable pdf2htmlEX /usr/local/lib/libfontforge.so: undefined reference to PyTuple_SetItem' /usr/local/lib/libfontforge.so: undefined reference to PyObject_SelfIter'

解决办法

修改一下link.txt就可以了 vim CMakeFiles/pdf2htmlEX.dir/link.txt 加上一个编译参数 -lpython2.6

问题5:

CMakeFiles/pdf2htmlEX.dir/3rdparty/poppler/git/CairoOutputDev.cc.o: In function CairoOutputDev::patchMeshShadedFill(GfxState*, GfxPatchMeshShading*)': CairoOutputDev.cc:(.text+0x1149): undefined reference to cairo_pattern_create_mesh' CairoOutputDev.cc:(.text+0x1195): undefined reference to cairo_mesh_pattern_begin_patch' CairoOutputDev.cc:(.text+0x11b0): undefined reference to cairo_mesh_pattern_move_to' CairoOutputDev.cc:(.text+0x11e9): undefined reference to cairo_mesh_pattern_curve_to' CairoOutputDev.cc:(.text+0x1222): undefined reference to cairo_mesh_pattern_curve_to' CairoOutputDev.cc:(.text+0x125b): undefined reference to `cairo_mesh_pattern_curve_to'

解决办法:

cmake -DENABLE_SVG=OFF . 就好了

问题6 :执行pdf2htmlex

[root@localhost office]# /usr/local/bin/pdf2htmlEX -l 210 --no-drm 1 --fit-width 1024 --dest-dir html --external-hint-tool="ttfautohint" --split-pages 0 "123.pdf" Preprocessing: 12/12 Segmentation fault

解决

遇到这样的情况,一般就是字体库是旧的,需要做处理 并将/usr/lib64 中老的动态链接库替换成最新的(/usr/lib/libfontforge.so) 记得是 cp /usr/lib/libfontforge.so /usr/lib64

问题7:

pdf2htmlEx: symbol lookup error: /usr/local/lib/libreadline.so.6: undefined symbol: PC

解决:

find /* -name libreadline.so.6 /lib64/libreadline.so.6 /usr/local/lib/libreadline.so.6 [root@www pdf]# mv /usr/local/lib/libreadline.so.6 /usr/local/lib/libreadline.so.6.bak [root@www pdf]# cp /lib64/libreadline.so.6 /usr/local/lib/libreadline.so.6