Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I build libpoppler from source?

I just download poppler to Linux system,and I want to incorporate it in my app to parse pdf file.
(My goal is to convert pdf file to plain text.)
How can I do this?

like image 333
zxi Avatar asked Dec 28 '22 07:12

zxi


2 Answers

Poppler's git tree includes a useless INSTALL doc that just tells you to run ./configure, but they don't include automake/autoconf auto-generated files (including configure) in git. (Probably they do include them in tarball source releases.)

I just built poppler from git source (on Ubuntu 15.04) like so:

git clone --depth 50 --no-single-branch git://git.freedesktop.org/git/poppler/poppler
cmake -G 'Unix Makefiles'  # other -G options are to generate project files for various IDEs
# look at the output.  If it didn't find some libraries,
# install them with your package manager and re-run cmake
make -j4
# optionally:
sudo make install

It appears that they maintain an autoconf/automake build setup, so you can use that OR cmake to create a Makefile.

If you just want to see if the latest git poppler works better than the distro package, you don't need to sudo make install, you can just run utils/pdftotext or whatever right from the source directory. It apparently tells the linker to embed the build path into the binary, as a library search path, so running /usr/local/src/poppler/utils/pdftotext works, and finds /usr/local/src/poppler/libpoppler.so.52.

If the latest poppler does work better than the distro-packaged poppler, you should install it to /usr/local/bin with sudo make install. When you upgrade to the next version of your distro, check your /usr/local. Often the new distro version will be newer than when you built it from source, so you should just remove your version from /usr/local/{bin,share,lib,man,include}. (Or make uninstall in the source dir, if supported).

like image 105
Peter Cordes Avatar answered Dec 30 '22 11:12

Peter Cordes


Their website explains it very clearly :

Poppler is available from git. To clone the repository use the following command:

git clone git://git.freedesktop.org/git/poppler/poppler

Once you download the source code, read the INSTALL file where it says :

  1. cd to the directory containing the package's source code and type ./configure to configure the package for your system.

  2. Type `make' to compile the package.

  3. Type `make install' to install the programs and any data files and documentation.

like image 20
BЈовић Avatar answered Dec 30 '22 12:12

BЈовић