ropensci/pdftools

Problem installing: Undefined Symbol

ivlachos opened this issue · 7 comments

Hi,

We're having a really hard timing installing on a new server. Everything seems to be in place (poppler, etc).

The error is similar to #9 but we have a single poppler version installed (which we reinstalled using yum).

Tried to install also the package from source, within R-Studio, or directly from R but the error is always the same.

Can you please give us a hand?

thank you

* 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  
** libs
g++ -m64 -std=gnu++11 -I"/usr/include/R" -DNDEBUG -I/usr/include/poppler/cpp -I/usr/include/poppler   -I"/data/resources/tools/R/3.6/library/Rcpp/include" -I/usr/local/include -fvisibility=hidden -fpic  -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches   -m64 -mtune=generic  -c RcppExports.cpp -o RcppExports.o
g++ -m64 -std=gnu++11 -I"/usr/include/R" -DNDEBUG -I/usr/include/poppler/cpp -I/usr/include/poppler   -I"/data/resources/tools/R/3.6/library/Rcpp/include" -I/usr/local/include -fvisibility=hidden -fpic  -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches   -m64 -mtune=generic  -c bindings.cpp -o bindings.o
bindings.cpp:389:13: warning: ‘void error_callback(const string&, void*)’ defined but not used [-Wunused-function]
 static void error_callback(const std::string &msg, void *context){
             ^~~~~~~~~~~~~~
g++ -m64 -std=gnu++11 -shared -L/usr/lib64/R/lib -Wl,-z,relro -o pdftools.so RcppExports.o bindings.o -lpoppler-cpp -L/usr/lib64/R/lib -lR
installing to /data/resources/tools/R/3.6/library/00LOCK-pdftools/00new/pdftools/libs
** R
** byte-compile and prepare package for lazy loading
** help
*** installing help indices
  converting help for package ‘pdftools’
    finding HTML links ... done
    pdf_ocr                                 html  
    pdf_render_page                         html  
    pdftools                                html  
    qpdf                                    html  
Rd warning: /tmp/Rtmpltbl8n/R.INSTALL1ee9826df80ba/pdftools/man/qpdf.Rd:26: file link ‘pdf_combine’ in package ‘qpdf’ does not exist and so has been treated as a topic
Rd warning: /tmp/Rtmpltbl8n/R.INSTALL1ee9826df80ba/pdftools/man/qpdf.Rd:26: file link ‘pdf_compress’ in package ‘qpdf’ does not exist and so has been treated as a topic
Rd warning: /tmp/Rtmpltbl8n/R.INSTALL1ee9826df80ba/pdftools/man/qpdf.Rd:26: file link ‘pdf_length’ in package ‘qpdf’ does not exist and so has been treated as a topic
Rd warning: /tmp/Rtmpltbl8n/R.INSTALL1ee9826df80ba/pdftools/man/qpdf.Rd:26: file link ‘pdf_split’ in package ‘qpdf’ does not exist and so has been treated as a topic
Rd warning: /tmp/Rtmpltbl8n/R.INSTALL1ee9826df80ba/pdftools/man/qpdf.Rd:26: file link ‘pdf_subset’ in package ‘qpdf’ does not exist and so has been treated as a topic
** 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 '/data/resources/tools/R/3.6/library/00LOCK-pdftools/00new/pdftools/libs/pdftools.so':
  /data/resources/tools/R/3.6/library/00LOCK-pdftools/00new/pdftools/libs/pdftools.so: undefined symbol: _ZNK7poppler7ustring9to_latin1B5cxx11Ev**
Error: loading failed
Execution halted
ERROR: loading failed
* removing ‘/data/resources/tools/R/3.6/library/pdftools’

What operating system do you use? Are you using a custom gcc by any chance?

Hi it's RHEL 7 and yes in all profiles there was a gcc module loaded for gcc 8.2 while native was still 4.8.5. Removed and installed like a charm.
Thank you. Good catch

Hi it's RHEL 7 and yes in all profiles there was a gcc module loaded for gcc 8.2 while native was still 4.8.5. Removed and installed like a charm. Thank you. Good catch

Dear Ioannis,

Could you please give more details regarding gcc module. What exactly have you done? We have a similar issue and a couple different gcc installed. One from yum gcc 4.8.5 and other from sources (7.5.0)

It is indeed the reason. I have removed the gcc 9.2 from the PATH and only used gcc 4.8. It is done!

I also get Error: package or namespace load failed for ‘pdftools’ in dyn.load(file, DLLpath = DLLpath, ...): unable to load shared object '/home/gleixner/R/x86_64-pc-linux-gnu-library/4.1.0d/00LOCK-pdftools/00new/pdftools/libs/pdftools.so': /home/gleixner/R/x86_64-pc-linux-gnu-library/4.1.0d/00LOCK-pdftools/00new/pdftools/libs/pdftools.so: undefined symbol: _ZNK7poppler7ustring9to_latin1B5cxx11Ev. And yes I am also using a non-default version of gcc (gcc/11.1.0) instead of the system default (4.8.5). But all my R (c/cpp) packages (including RCPP) are compiled with with that version, so I cannot just use the system default. I guess I have to compile poppler with gcc 11.1.0 now?

I guess I have to compile poppler with gcc 11.1.0 now?

That is one way but it is easier to compile pdftools with gcc 4.8.5. Temporarily set this in your ~/.R/Makevars:

CXX=/usr/bin/g++ -std=gnu++11

After the installation has succeeded you can remove this again.

Alternatively may just be to install the precompiled binary package from Posit which does not require any compilation. For example if you are on R-4.3 on centos-7:

install.packages("https://packagemanager.posit.co/cran/__linux__/centos7/latest/src/contrib/pdftools_3.3.3.tar.gz?r_version=4.3&arch=x86_64", repos = NULL)

Thank you! You're a life saver. Both solutions work well! & I learned that I can just use the system version while leaving the gcc/11.1.0 module active (/without modifying $path etc) ( and thus e.g. RCPP runtime requirements available) by explicitly telling R which compiler to use via ~/.R/Makevars. This will probably help me quite a bit in the future as well!