4

I am trying to install R’s plyr package. Here is the error message:

* installing *source* package ‘plyr’ ...
** package ‘plyr’ successfully unpacked and MD5 sums checked
** libs
clang++  -I/opt/R-3.4.1/include -DNDEBUG  -I"/home/isomorphismes/R/i686-pc-linux-gnu-library/3.4/Rcpp/include" -I/usr/local/include   -fpic  -I/opt/boost_1_61_0/boost -c RcppExports.cpp -o RcppExports.o
clang -I/opt/R-3.4.1/include -DNDEBUG  -I"/home/cd/R/i686-pc-linux-gnu-library/3.4/Rcpp/include" -I/usr/local/include   -fpic  -g -O2 -flto -c loop_apply.c -o loop_apply.o
clang++  -I/opt/R-3.4.1/include -DNDEBUG  -I"/home/isomorphismes/R/i686-pc-linux-gnu-library/3.4/Rcpp/include" -I/usr/local/include   -fpic  -I/opt/boost_1_61_0/boost -c split-numeric.cpp -o split-numeric.o
clang++ -shared -L/usr/local/lib -o plyr.so RcppExports.o loop_apply.o split-numeric.o
loop_apply.o: file not recognized: File format not recognized
clang: error: linker command failed with exit code 1 (use -v to see invocation)
/opt/R-3.4.1/share/make/shlib.mk:6: recipe for target 'plyr.so' failed
make: *** [plyr.so] Error 1
ERROR: compilation failed for package ‘plyr’
* removing ‘/home/cd/R/i686-pc-linux-gnu-library/3.4/plyr’

The *.o files are in /opt/plyr/src, from github.com/hadley/plyr. They look like this on my system:

i@scheherezade:/opt/plyr/src$ file *o
loop_apply.o:    LLVM IR bitcode
RcppExports.o:   ELF 32-bit LSB relocatable, Intel 80386, version 1 (SYSV), not stripped
split-numeric.o: ELF 32-bit LSB relocatable, Intel 80386, version 1 (SYSV), not stripped
isomorphismes
  • 8,233
  • 9
  • 59
  • 70

2 Answers2

2

In case you didn't know, -flto specifies link time optimization, and has been added by R. How did you manage to end up with such a mis-configured R install?

Adding -flto to the link command may work? Or remove it from the loop_apply compilation line. If either of those works, you need to fix your R install.

DaBookshah
  • 186
  • 6
  • Hah. By ignoring @TonyFischetti's advice here: http://www.onthelambda.com/2013/11/22/compiling-r-from-source-and-why-you-shouldnt-do-it/ Thanks, DaBookshah. – isomorphismes Sep 07 '17 at 19:26
  • I’m not sure how to change the install pocess (like changing the compilation lines or the linker), but compiling without `./configure --enable-lto`. I guess this question provides an answer to https://stackoverflow.com/questions/23736507/is-there-any-reason-why-not-to-use-link-time-optimization ? – isomorphismes Sep 07 '17 at 20:48
  • *but compiling without `./configure --enable-lto` solved it. – isomorphismes Sep 07 '17 at 23:37
  • 1
    For future reference, you can change the package install process by editing the Makeconf file. On windows it's under /etc/x64/Makeconf. On other platforms it will be somewhere similar. Although editing this file would probably *not* be the recommended way of solving the problem you gave here. – DaBookshah Sep 09 '17 at 00:22
  • Thanks, @DaBookshah! – isomorphismes Sep 13 '17 at 16:45
0

Compiling with -flto using clang requires (on Ubuntu) installing the llvm-dev package. Otherwise, the linker is unable to handle -flto object files.

apt-get install clang-10 llvm-10-dev

Now the linking should succeed.

user7610
  • 25,267
  • 15
  • 124
  • 150