ropensci / pdftools

Text Extraction, Rendering and Converting of PDF Documents
https://docs.ropensci.org/pdftools
Other
524 stars 71 forks source link

Install error #114

Closed shirdekel closed 2 years ago

shirdekel commented 2 years ago

Running install.packages("pdftools", type = "source") gives me the below error.

trying URL 'https://cloud.r-project.org/src/contrib/pdftools_3.2.1.tar.gz'
Content type 'application/x-gzip' length 936059 bytes (914 KB)
==================================================
downloaded 914 KB

* 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/opt/homebrew/Cellar/poppler/22.05.0/include/poppler/cpp -I/opt/homebrew/Cellar/poppler/22.05.0/include/poppler
Using PKG_LIBS=-L/opt/homebrew/Cellar/poppler/22.05.0/lib -lpoppler-cpp
Found poppler-data in /opt/homebrew/Cellar/poppler/22.05.0/share/poppler
** libs
g++-11 -std=gnu++11 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I/opt/homebrew/Cellar/poppler/22.05.0/include/poppler/cpp -I/opt/homebrew/Cellar/poppler/22.05.0/include/poppler -DBUNDLE_POPPLER_DATA -I'/Library/Frameworks/R.framework/Versions/4.2-arm64/Resources/library/Rcpp/include' -I/opt/R/arm64/include   -fPIC  -falign-functions=64 -Wall -g -O2  -c RcppExports.cpp -o RcppExports.o
g++-11 -std=gnu++11 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I/opt/homebrew/Cellar/poppler/22.05.0/include/poppler/cpp -I/opt/homebrew/Cellar/poppler/22.05.0/include/poppler -DBUNDLE_POPPLER_DATA -I'/Library/Frameworks/R.framework/Versions/4.2-arm64/Resources/library/Rcpp/include' -I/opt/R/arm64/include   -fPIC  -falign-functions=64 -Wall -g -O2  -c bindings.cpp -o bindings.o
bindings.cpp: In function 'Rcpp::List poppler_pdf_info(Rcpp::RawVector, std::string, std::string)':
bindings.cpp:146:45: warning: 'poppler::time_type poppler::document::info_date(const string&) const' is deprecated [-Wdeprecated-declarations]
  146 |       _["created"] = Datetime(doc->info_date("CreationDate")),
      |                               ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~
In file included from bindings.cpp:4:
/opt/homebrew/Cellar/poppler/22.05.0/include/poppler/cpp/poppler-document.h:75:30: note: declared here
   75 |     [[deprecated]] time_type info_date(const std::string &key) const;
      |                              ^~~~~~~~~
bindings.cpp:147:46: warning: 'poppler::time_type poppler::document::info_date(const string&) const' is deprecated [-Wdeprecated-declarations]
  147 |       _["modified"] = Datetime(doc->info_date("ModDate")),
      |                                ~~~~~~~~~~~~~~^~~~~~~~~~~
In file included from bindings.cpp:4:
/opt/homebrew/Cellar/poppler/22.05.0/include/poppler/cpp/poppler-document.h:75:30: note: declared here
   75 |     [[deprecated]] time_type info_date(const std::string &key) const;
      |                              ^~~~~~~~~
bindings.cpp:175:43: warning: 'poppler::time_type poppler::document::info_date(const string&) const' is deprecated [-Wdeprecated-declarations]
  175 |     _["created"] = Datetime(doc->info_date("CreationDate")),
      |                             ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~
In file included from bindings.cpp:4:
/opt/homebrew/Cellar/poppler/22.05.0/include/poppler/cpp/poppler-document.h:75:30: note: declared here
   75 |     [[deprecated]] time_type info_date(const std::string &key) const;
      |                              ^~~~~~~~~
bindings.cpp:176:44: warning: 'poppler::time_type poppler::document::info_date(const string&) const' is deprecated [-Wdeprecated-declarations]
  176 |     _["modified"] = Datetime(doc->info_date("ModDate")),
      |                              ~~~~~~~~~~~~~~^~~~~~~~~~~
In file included from bindings.cpp:4:
/opt/homebrew/Cellar/poppler/22.05.0/include/poppler/cpp/poppler-document.h:75:30: note: declared here
   75 |     [[deprecated]] time_type info_date(const std::string &key) const;
      |                              ^~~~~~~~~
bindings.cpp: In function 'Rcpp::List poppler_pdf_files(Rcpp::RawVector, std::string, std::string)':
bindings.cpp:355:52: warning: 'poppler::time_type poppler::embedded_file::creation_date() const' is deprecated [-Wdeprecated-declarations]
  355 |         _["created"] = Datetime(file->creation_date()),
      |                                 ~~~~~~~~~~~~~~~~~~~^~
In file included from bindings.cpp:8:
/opt/homebrew/Cellar/poppler/22.05.0/include/poppler/cpp/poppler-embedded-file.h:41:30: note: declared here
   41 |     [[deprecated]] time_type creation_date() const;
      |                              ^~~~~~~~~~~~~
bindings.cpp:356:57: warning: 'poppler::time_type poppler::embedded_file::modification_date() const' is deprecated [-Wdeprecated-declarations]
  356 |         _["modified"] = Datetime(file->modification_date()),
      |                                  ~~~~~~~~~~~~~~~~~~~~~~~^~
In file included from bindings.cpp:8:
/opt/homebrew/Cellar/poppler/22.05.0/include/poppler/cpp/poppler-embedded-file.h:40:30: note: declared here
   40 |     [[deprecated]] time_type modification_date() const;
      |                              ^~~~~~~~~~~~~~~~~
g++-11 -std=gnu++11 -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -L/Library/Frameworks/R.framework/Resources/lib -L/opt/R/arm64/lib -o pdftools.so RcppExports.o bindings.o -L/opt/homebrew/Cellar/poppler/22.05.0/lib -lpoppler-cpp -F/Library/Frameworks/R.framework/.. -framework R -Wl,-framework -Wl,CoreFoundation
ld: warning: dylib (/opt/homebrew/Cellar/gcc/11.3.0/lib/gcc/11/libstdc++.dylib) was built for newer macOS version (12.2) than being linked (12.0)
installing to /Library/Frameworks/R.framework/Versions/4.2-arm64/Resources/library/00LOCK-pdftools/00new/pdftools/libs
** R
** inst
** byte-compile and prepare package for lazy loading
** help
*** installing help indices
** building package indices
** testing if installed package can be loaded from temporary location
Error: package or namespace load failed for ‘pdftools’ in dyn.load(file, DLLpath = DLLpath, ...):
 unable to load shared object '/Library/Frameworks/R.framework/Versions/4.2-arm64/Resources/library/00LOCK-pdftools/00new/pdftools/libs/pdftools.so':
  dlopen(/Library/Frameworks/R.framework/Versions/4.2-arm64/Resources/library/00LOCK-pdftools/00new/pdftools/libs/pdftools.so, 0x0006): symbol not found in flat namespace '__ZN7poppler12set_data_dirERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE'
Error: loading failed
Execution halted
ERROR: loading failed
* removing ‘/Library/Frameworks/R.framework/Versions/4.2-arm64/Resources/library/pdftools’

The downloaded source packages are in
    ‘/private/var/folders/61/90npj48j5k5g3wtr27vwl1yr0000gn/T/RtmpXdSqCA/downloaded_packages’
Warning message:
In install.packages("pdftools", type = "source") :
  installation of package ‘pdftools’ had non-zero exit status

g++ versions as per https://github.com/ropensci/pdftools/issues/112:

g++ --version
Configured with: --prefix=/Library/Developer/CommandLineTools/usr --with-gxx-include-dir=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/4.2.1
Apple clang version 13.0.0 (clang-1300.0.29.30)
Target: arm64-apple-darwin21.1.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin
/usr/bin/g++ --version
Configured with: --prefix=/Library/Developer/CommandLineTools/usr --with-gxx-include-dir=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/4.2.1
Apple clang version 13.0.0 (clang-1300.0.29.30)
Target: arm64-apple-darwin21.1.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin

Session info:

xfun::session_info()
> R version 4.2.0 (2022-04-22)
Platform: aarch64-apple-darwin20 (64-bit)
Running under: macOS Monterey 12.0.1

Locale: en_GB.UTF-8 / en_GB.UTF-8 / en_GB.UTF-8 / C / en_GB.UTF-8 / en_GB.UTF-8

Package version:
  compiler_4.2.0  graphics_4.2.0  grDevices_4.2.0 stats_4.2.0    
  tools_4.2.0     utils_4.2.0     xfun_0.30      
jeroen commented 2 years ago

Can you try compiling with the standard clang from xcode, rather than gcc?

shirdekel commented 2 years ago

Is that something that I can do from within R?

jeroen commented 2 years ago

How did you install R? It may be set in your ~/.R/Makevars file

shirdekel commented 2 years ago

Turns out that I had previously set R to compile with gcc in my ~/.R/Makevars file. Commenting this out and restarting fixed my issue. I think this means that R has now reverted to using clang as is defined in /Library/Frameworks/R.framework/Versions/4.2-arm64/Resources/etc/Makeconf.