1

I read the post How install poppler and was hopeful regarding my own difficulty, but no dice.

I am running R under Anaconda on a Ubuntu 18.04 Precision laptop. I wanted to install readtext (R package) to support some corpora linguistics study and attempted that from R terminal window. I had already installed quanteda without a problem so was surprised when readtext tripped on a pdftools requirement which in turn tripped

cannot find -lpoppler-cpp

I had already installed and uninstalled libpoppler-cpp-dev several times using

sudo apt-get install -y libpoppler-cpp-dev

That installed ok

libpoppler-cpp-dev is already the newest version (0.74.0-bionic0)

When I attempt the readtext install from R (again, running under Anaconda, which might be problem), it arrives at the pdftools install and finds the local pkg-config info

  • installing source package ‘pdftools’ ... ** package ‘pdftools’ successfully unpacked and MD5 sums checked ** using staged installation Found pkg-config cflags and libs! Using PKG_CFLAGS=-I/usr/include/poppler/cpp -I/usr/include/poppler Using PKG_LIBS=-lpoppler-cpp

But then cannot find it:

/home/dalton/anaconda3/bin/../lib/gcc/x86_64-conda_cos6-linux-gnu/7.3.0/../../../../x86_64-conda_cos6-linux-gnu/bin/ld: cannot find -lpoppler-cpp collect2: error: ld returned 1 exit status make: *** [/home/dalton/anaconda3/lib/R/share/make/shlib.mk:6: pdftools.so] Error 1 ERROR: compilation failed for package ‘pdftools’

  • removing ‘/home/dalton/anaconda3/lib/R/library/pdftools’

When I check pkg-config myself:

pkg-config --cflags --libs poppler-cpp

-I/usr/include/poppler/cpp -I/usr/include/poppler -lpoppler-cpp

I indeed find the same information the installer in R finds. When I chased down poppler with a system grep:

ls --recursive | grep -E "poppler"

I do not find poppler-cpp, though I find libpoppler-cpp-dev and other libpoppler-cpp files/folders. However, if I interrogate pkg-config:

pkg-config --cflags --libs libpoppler-cpp-dev

It tells me

Package libpoppler-cpp-dev was not found in the pkg-config search path. Perhaps you should add the directory containing `libpoppler-cpp-dev.pc' to the PKG_CONFIG_PATH environment variable. No package 'libpoppler-cpp-dev' found.

I used the PPA with backports of Poppler 0.74.0 for Ubuntu 18.04 (Bionic) recommended by @jeroen in the cited SE post above, but it appears there is some confusion between the Ubuntu proper and Anaconda R, since the R install is looking for poppler-cpp, but libpoppler-cpp-dev seems to be the appropriate target. Because I am running R under Anaconda, my system seems unaware of R:

apt-cache policy r-base-core

returns

r-base-core: Installed: (none) Candidate: 3.4.4-1ubuntu1 Version table: 3.4.4-1ubuntu1 500 500 http://us.archive.ubuntu.com/ubuntu bionic/universe amd64 Packages

I realize this is all somewhat of a mess, but I am hoping someone will recognize an obvious problem and tell me what to hack up, e.g., modify the poppler-cpp.pc to point at the new library or the like.

  • 1
    Remember Ubuntu package names and pkg-config package names are not the same: the pkg-config file provided by libpopplar-cpp-dev is named poppler-cpp.pc indicating that you'd query it as pkg-config --cflags --libs poppler-cpp – steeldriver May 12 '21 at 14:28
  • 1
    ... I guess the question I'd be asking is what the anaconda gcc's library search paths are (using path/to/anaconda/gcc -print-search-dirs for example) – steeldriver May 12 '21 at 14:32
  • @steeldrive Thanks for those comments. I will update here if make any progress. – Dalton Bentley May 13 '21 at 14:00

1 Answers1

1

The solution is to remain within the Anaconda/conda environment, since R is running there and this is a bit of an island within the surrounding Ubuntu sea (if the metaphor is not making you seasick). Just do

conda install -c conda-forge poppler

That took quite a while to finish, since the initial two attemtps to "solve the environment" failed, but conda finally tried another repodata source and succeeded:

package                    |            build
---------------------------|-----------------
certifi-2019.9.11          |           py37_0         147 KB  conda-forge
conda-4.10.1               |   py37h89c1867_0         3.1 MB  conda-forge
openjpeg-2.3.1             |       h21c5421_1         469 KB  conda-forge
poppler-0.65.0             |       h581218d_1         1.3 MB
poppler-data-0.4.10        |                0         3.8 MB  conda-forge
python_abi-3.7             |          1_cp37m           4 KB  conda-forge
------------------------------------------------------------
                                       Total:         8.7 MB

etc., ending with the blessed

Executing transaction: done

Then I opened a terminal window and started R:

dalton@dalton-Precision-3541:$ R

R version 3.6.1 (2019-07-05) -- "Action of the Toes" Copyright (C) 2019 The R Foundation for Statistical Computing Platform: x86_64-conda_cos6-linux-gnu (64-bit)

and installed pdftools:

> install.packages("pdftools")
  • installing source package ‘pdftools’ ... ** package ‘pdftools’ successfully unpacked and MD5 sums checked ** using staged installation Found pkg-config cflags and libs! Using PKG_CFLAGS=-I/usr/include/poppler/cpp -I/usr/include/poppler Using PKG_LIBS=-lpoppler-cpp

etc. For those are interested, the Anaconda library files were in areas like

-lpoppler-cpp -L/home/dalton/anaconda3/lib/R/lib -lR

In other words, after the conda installation of poppler, my R install of pdftools could find poppler-cpp. pdftools completed:

** testing if installed package keeps a record of temporary installation path

  • DONE (pdftools)

I then was able to complete my original task of installing readtext, which required poppler and pdftools:

install.packages("readtext")

** testing if installed package keeps a record of temporary installation path

  • DONE (readtext)

The downloaded source packages are in ‘/tmp/Rtmpxksozx/downloaded_packages’ Updating HTML index of packages in '.Library' Making 'packages.html' ... done

library(readtext)

All is good with the world, the convoluted world of Anaconda/conda within Ubuntu. It is a great environment for scientific and academic computing, once you figure out how to communicate.