How can I build libpoppler from source?
Asked Answered
S

4

5

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?

Stripteaser answered 17/1, 2012 at 5:59 Comment(7)
What did you try? What form of "poppler" did you download? Have you read the release and installing notices?Hypnotism
actually all I need is "pdftotext"Stripteaser
apt-cache search pdftotext suggests to install the poppler-utils package on my Debian system. But then you are not incorporating it into your application. IMHO, incorporating a library inside your software means calling that library, and linking with it.Hypnotism
Many thanks for your help! I want to build a shared library with the same ability of "pdftotext" from the poppler code.Stripteaser
Do not build software from source if a package for your OS exists. If you need to use a library in your software, install developer's version of the library (on Ubuntu that would be libpoppler-dev).Dobrinsky
OK! But How Can I get the lib and relative manual?Stripteaser
You need to install relevant packages. On Debian or Ubuntu, probably with apt-get install libpoppler-devHypnotism
M
1

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.

Merissameristem answered 17/1, 2012 at 7:53 Comment(1)
Their INSTALL file is the default auto-generated instructions, which don't actually apply to poppler. Their git tree doesn't include the autoconf outputs (including configure), only the inputs for autoconf/automake, and also cmake. I'm still trying to figure out which order to run things in. The usual ./configure && make -j4 && sudo make install probably works with their tarball releases, but not git.Analogy
A
11

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).

Analogy answered 17/6, 2015 at 0:13 Comment(2)
Thank you. I realize this is old, but the accepted answer is not really helpful as the INSTALL information is incorrect, and cmake is indeed needed as you wrote. Still working on dependencies, but this got me going; I'm a cmake neophyte so I needed a shove.Abscess
It seems they also improved their INSTALL file, saying pretty much the same now.Conveyancer
M
1

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.

Merissameristem answered 17/1, 2012 at 7:53 Comment(1)
Their INSTALL file is the default auto-generated instructions, which don't actually apply to poppler. Their git tree doesn't include the autoconf outputs (including configure), only the inputs for autoconf/automake, and also cmake. I'm still trying to figure out which order to run things in. The usual ./configure && make -j4 && sudo make install probably works with their tarball releases, but not git.Analogy
T
0

Since some time has passed and it seems there was some uncertainty, I also took a look.

At the end of 2021, their homepage says

We run continuous integration via the gitlab CI

I checked out their .gitlab-ci.yml which has many build tasks. It would seem these days we build libpoppler like this:

git clone git://git.freedesktop.org/git/poppler/test test.repo
mkdir -p build && cd build
cmake -DTESTDATADIR=`pwd`/../test.repo -G Ninja ..
ninja
Test answered 31/12, 2021 at 13:52 Comment(0)
H
0

If you want to install poppler from source without affecting the poppler from your system (distro provided) I recommend JHBuild, as easy as:

jhbuild buildone poppler-data poppler-test-files poppler
Headless answered 10/5 at 17:8 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.