14

I am using R server on Windows and I need to extract the text of thousands of pdf documents (in order to extract specific data). Thus, I need to install the package "pdftools", though when I do the command to install it :

install.packages("pdftools")

I get the following error :

Installing package into ‘/home/allusers/recette/R/x86_64-redhat-linux-gnu-library/3.4’

(as ‘lib’ is unspecified)
trying URL 'https://cran.rstudio.com/src/contrib/pdftools_1.5.tar.gz'
Content type 'application/x-gzip' length 811447 bytes (792 KB)

==================================================
downloaded 792 KB

* installing *source* package ‘pdftools’ ...
** package ‘pdftools’ successfully unpacked and MD5 sums checked
Package poppler-cpp was not found in the pkg-config search path.
Perhaps you should add the directory containing `poppler-cpp.pc'
to the PKG_CONFIG_PATH environment variable
No package 'poppler-cpp' found
Using PKG_CFLAGS=-I/usr/include/poppler/cpp -I/usr/include/poppler
Using PKG_LIBS=-lpoppler-cpp

------------------------- ANTICONF ERROR ---------------------------
Configuration failed because poppler-cpp was not found. Try installing:
 * deb: libpoppler-cpp-dev (Debian, Ubuntu, etc)
 * rpm: poppler-cpp-devel (Fedora, CentOS, RHEL)
 * csw: poppler_dev (Solaris)
 * brew: poppler (Mac OSX)
If poppler-cpp is already installed, check that 'pkg-config' is in your
PATH and PKG_CONFIG_PATH contains a poppler-cpp.pc file. If pkg-config
is unavailable you can set INCLUDE_DIR and LIB_DIR manually via:
R CMD INSTALL --configure-vars='INCLUDE_DIR=... LIB_DIR=...'
--------------------------------------------------------------------

ERROR: configuration failed for package ‘pdftools’
* removing ‘/home/allusers/recette/R/x86_64-redhat-linux-gnu-library/3.4/pdftools’
Warning in install.packages :
  installation of package ‘pdftools’ had non-zero exit status

The downloaded source packages are in
    ‘/tmp/Rtmp3ZNfGJ/downloaded_packages’

Did this happen to anyone before? Also I get that the error comes from "poppler-cpp". Thus I tried to install the package "poppler-cpp" but I get the following error cause this is not available for the 3.4.1 R version

Warning in install.packages :
  package ‘poppler-cpp’ is not available (for R version 3.4.1)

Update : Writing this command in the terminal worked

$ sudo yum install poppler-cpp-devel

But then another error showed :

Error in .shlib_internal(args) : 
  C++11 standard requested but CXX11 is not defined
Amandine.G
  • 181
  • 1
  • 2
  • 9

3 Answers3

26

Have you try to install in the terminal libpoppler-cpp-dev?

Open the terminal (ctrl+alt+t) and write:

sudo apt-get install libpoppler-cpp-dev
Daniel Gimenez
  • 551
  • 3
  • 6
  • Could not find a version that satisfies the requirement libpoppler-cpp-dev (from versions: ) No matching distribution found for libpoppler-cpp-dev – Jaswinder Jan 18 '19 at 09:53
6

On OSX, I was able to fix this by installing pkg-config, which I believe helps the R pdftools package locate the appropriate configuration for poppler:

brew install pkg-config
user126350
  • 505
  • 5
  • 11
  • this is the best solution - removing the misleading error message after unsuccessful pdftools installation: `If poppler-cpp is already installed, check that pkg-config is in your PATH and PKG_CONFIG_PATH contains a poppler-cpp.pc file. If pkg-config is unavailable you can set INCLUDE_DIR and LIB_DIR manually via: R CMD INSTALL --configure-vars="INCLUDE_DIR=... LIB_DIR=..." ` – Agile Bean Dec 13 '19 at 10:36
  • It works for me, so finally I used: brew install poppler (last long) and brew install pkg-config. pdftools finally compiled on R. THX – i love mistaking May 06 '20 at 11:28
  • brew install popper followed by brew install pkg-config worked for me thanks. – C Jones Jul 16 '20 at 14:14
2

Also on OSX, I was able to fix the above problem by installing poppler, which I can see that it is a package missing as seen in your error feed

brew install poppler
shiramy
  • 789
  • 8
  • 13
  • 1
    The other two solutions didn't immediately work for me and would have required more troubleshooting, but "brew install poppler" fixed everything. The catch is that maybe it took an hour to run "brew install poppler." – windyvation Sep 04 '20 at 18:05