Search code examples
rcompiler-errorsiccintel-mkl

Intel compiler - Can't install packages in R that require eventloop.h


Seems like I can't install any packages in R that require any files to be compiled. eventloop.h

I did a custom install of R with intel compilers and linked to the intel MKL BLAS library.

Here is the specific error I am getting:

> install.packages("setwidth")
Installing package into ‘/usr/local/lib/R/site-library’
(as ‘lib’ is unspecified)
Selection: 77
trying URL 'http://streaming.stat.iastate.edu/CRAN/src/contrib/setwidth_1.0-3.tar.gz'
Content type 'application/x-gzip' length 3789 bytes
opened URL
==================================================
downloaded 3789 bytes

* installing *source* package ‘setwidth’ ...
** package ‘setwidth’ successfully unpacked and MD5 sums checked
** libs
icc -std=c99 -I/usr/local/lib/R/include -DNDEBUG  -I/usr/local/include    -fpic  -O3 -ipo -xavx -openmp  -c setwidth.c -o setwidth.o
In file included from setwidth.c(4):
/usr/local/lib/R/include/R_ext/eventloop.h(73): error: identifier "fd_set" is undefined
  extern InputHandler *getSelectedHandler(InputHandler *handlers, fd_set *mask);
                                                                  ^
... more of the same ...

                  ^

compilation aborted for setwidth.c (code 2)
make: *** [setwidth.o] Error 2
ERROR: compilation failed for package ‘setwidth’
* removing ‘/usr/local/lib/R/site-library/setwidth’

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

Let me know any additional info you might need to help me troubleshoot this.

EDIT:

I tried adding

R_XTRA_CFLAGS = -I /src/include -I /src/include/sys 

to my ~/.R/Makevars file because fd_set is defined in /sys/select.h No luck with that anyone have any ideas???

EDIT:

So this problem does not occur with every package, only packages that require certain R headers. So far I have only had problems with packages written by a certain author (all the packages required for integration of R with VIM, http://www.lepem.ufc.br/jaa/vim-r-plugin.html) Does anyone have any ideas?

EDIT:

seems to be a compiler issue:

gcc -I /usr/include/ -I /usr/local/lib/R/include/ -c setwidth.c

works however

icc -std=c99 -I /usr/include -I /usr/local/lib/R/include  -O3 -ipo -xavx -openmp -c setwidth.c

does not


Solution

  • Not sure if this was an appropriate solution but when I peeked inside of /usr/local/lib/R/include/R_ext/eventloop.h I saw the following in the include statements:

    #ifndef R_EXT_EVENTLOOP_H
    #define R_EXT_EVENTLOOP_H
    
    #ifndef NO_C_HEADERS
    #ifdef HAVE_SYS_SELECT_H
    # include <sys/select.h>    /* for fd_set according to recent POSIX */
    #endif
    /* NOTE: Needed at least on FreeBSD so that fd_set is defined. */
    # include <sys/types.h>
    #endif
    

    As you can see sys/select.h is only included conditional on some variable HAVE_SYS_SELECT_H. I took out this condition statement:

    #ifndef R_EXT_EVENTLOOP_H
    #define R_EXT_EVENTLOOP_H
    
    #ifndef NO_C_HEADERS
    # include <sys/select.h>    /* for fd_set according to recent POSIX */
    /* NOTE: Needed at least on FreeBSD so that fd_set is defined. */
    # include <sys/types.h>
    #endif
    

    And the package compiled (and installed) successfully. If anyone has any insight into why this particular variable HAVE_SYS_SELECT_H was not properly defined please let me know.