randy3k / collections

High-performance container datatypes for R
https://randy3k.github.io/collections
Other
103 stars 3 forks source link

compilation error in Eigen during installation on linux #19

Open lyinch opened 2 years ago

lyinch commented 2 years ago

Hello,

When I try to install the package on linux I get a strange compilation error:

> install.packages("collections")
Installing package into ‘/home/backes/R/x86_64-pc-linux-gnu-library/4.1’
(as ‘lib’ is unspecified)
trying URL 'https://stat.ethz.ch/CRAN/src/contrib/collections_0.3.5.tar.gz'
Content type 'application/x-gzip' length 93547 bytes (91 KB)
==================================================
downloaded 91 KB

* installing *source* package ‘collections’ ...
** package ‘collections’ successfully unpacked and MD5 sums checked
** using staged installation
** libs
gcc -I"/usr/include/R/" -DNDEBUG   -I"/home/backes/R/x86_64-pc-linux-gnu-library/4.1/Rcpp/include/"  -I"/home/backes/R/x86_64-pc-linux-gnu-library/4.1/RcppEigen/include/"  -I"/home/backes/R/x86_64-pc-linux-gnu-library/4.1/RcppEigen/include/unsupported"  -I"/home/backes/R/x86_64-pc-linux-gnu-library/4.1/BH/include" -I"/home/backes/R/x86_64-pc-linux-gnu-library/4.1/StanHeaders/include/src/"  -I"/home/backes/R/x86_64-pc-linux-gnu-library/4.1/StanHeaders/include/"  -I"/home/backes/R/x86_64-pc-linux-gnu-library/4.1/RcppParallel/include/"  -I"/home/backes/R/x86_64-pc-linux-gnu-library/4.1/rstan/include" -DEIGEN_NO_DEBUG  -DBOOST_DISABLE_ASSERTS  -DBOOST_PENDING_INTEGER_LOG2_HPP  -DSTAN_THREADS  -DBOOST_NO_AUTO_PTR  -include '/home/backes/R/x86_64-pc-linux-gnu-library/4.1/StanHeaders/include/stan/math/prim/mat/fun/Eigen.hpp'  -D_REENTRANT -DRCPP_PARALLEL_USE_TBB=1   -D_FORTIFY_SOURCE=2   -fpic  -march=x86-64 -mtune=generic -O2 -pipe -fno-plt  -c tommyds/tommy.c -o tommyds/tommy.o
In file included from /home/backes/R/x86_64-pc-linux-gnu-library/4.1/RcppEigen/include/Eigen/Core:88,
                 from /home/backes/R/x86_64-pc-linux-gnu-library/4.1/RcppEigen/include/Eigen/Dense:1,
                 from /home/backes/R/x86_64-pc-linux-gnu-library/4.1/StanHeaders/include/stan/math/prim/mat/fun/Eigen.hpp:13,
                 from <command-line>:
/home/backes/R/x86_64-pc-linux-gnu-library/4.1/RcppEigen/include/Eigen/src/Core/util/Macros.h:628:1: error: unknown type name ‘namespace’
  628 | namespace Eigen {
      | ^~~~~~~~~
/home/backes/R/x86_64-pc-linux-gnu-library/4.1/RcppEigen/include/Eigen/src/Core/util/Macros.h:628:17: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token
  628 | namespace Eigen {
      |                 ^
In file included from /home/backes/R/x86_64-pc-linux-gnu-library/4.1/RcppEigen/include/Eigen/Dense:1,
                 from /home/backes/R/x86_64-pc-linux-gnu-library/4.1/StanHeaders/include/stan/math/prim/mat/fun/Eigen.hpp:13,
                 from <command-line>:
/home/backes/R/x86_64-pc-linux-gnu-library/4.1/RcppEigen/include/Eigen/Core:96:10: fatal error: complex: No such file or directory
   96 | #include <complex>
      |          ^~~~~~~~~
compilation terminated.
make: *** [/usr/lib64/R/etc/Makeconf:168: tommyds/tommy.o] Error 1
ERROR: compilation failed for package ‘collections’
* removing ‘/home/backes/R/x86_64-pc-linux-gnu-library/4.1/collections’

The downloaded source packages are in
        ‘/tmp/RtmpdlcMoz/downloaded_packages’
Warning message:
In install.packages("collections") :
  installation of package ‘collections’ had non-zero exit status

I have R version 4.1.2:

R.version
               _                           
platform       x86_64-pc-linux-gnu         
arch           x86_64                      
os             linux-gnu                   
system         x86_64, linux-gnu           
status                                     
major          4                           
minor          1.2                         
year           2021                        
month          11                          
day            01                          
svn rev        81115                       
language       R                           
version.string R version 4.1.2 (2021-11-01)
nickname       Bird Hippie  

and the compiler is version 11.1.0 :

$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-pc-linux-gnu/11.1.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: /build/gcc/src/gcc/configure --prefix=/usr --libdir=/usr/lib --libexecdir=/usr/lib --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=https://bugs.archlinux.org/ --enable-languages=c,c++,ada,fortran,go,lto,objc,obj-c++,d --with-isl --with-linker-hash-style=gnu --with-system-zlib --enable-__cxa_atexit --enable-cet=auto --enable-checking=release --enable-clocale=gnu --enable-default-pie --enable-default-ssp --enable-gnu-indirect-function --enable-gnu-unique-object --enable-install-libiberty --enable-linker-build-id --enable-lto --enable-multilib --enable-plugin --enable-shared --enable-threads=posix --disable-libssp --disable-libstdcxx-pch --disable-libunwind-exceptions --disable-werror gdc_include_dir=/usr/include/dlang/gdc
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 11.1.0 (GCC) 

Has someone else also encountered the same issue or knows how to fix it?

Thank you

randy3k commented 2 years ago

collections does not use Rcpp at all. Not sure why you have those compilation flags. Did you modify the .Renviron file?

lyinch commented 2 years ago

No, I installed R with this package: https://archlinux.org/packages/extra/x86_64/r/ and besides installing R packages didn't change any dotfile.

randy3k commented 2 years ago

I am pretty sure you have messed up the compilation flags for R. Try running this to see what flags you have.

pkgbuild::compiler_flags()
lyinch commented 2 years ago

Thank you for taking time debugging this. That's the output, it looks normal and doesn't have all the flags from before

> pkgbuild::compiler_flags()
           CFLAGS          CXXFLAGS        CXX11FLAGS 
"-Wall -pedantic" "-Wall -pedantic" "-Wall -pedantic"