Pergunta

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

Foi útil?

Solução 2

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.

Outras dicas

Let's back up a little:

  1. Ubuntu is extremely widely used with R.

  2. You could just install the prebuilt current binary from CRAN

  3. You could then add the MKL as the BLAS are interchangeble due to their standard interface. (This is frequently misunderstood; see my gcbd vignette for some details)

  4. By staying with a more common setup, you can easily compile packages, or get prebuilt ones.

  5. And you can then study your Intel icc setup a little more closely.

Currently it is broken, and you get to keep both pieces.

Edit: To make it more plain, on a standard Ubuntu system with the Ubuntu binary package off CRAN:

edd@max:~$ install.r setwdith
Warning message:
package ‘setwdith’ is not available (for R version 3.0.2) 
edd@max:~$ install.r setwidth
trying URL 'http://cran.r-project.org/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
ccache gcc-4.8 -I/usr/share/R/include -DNDEBUG      -fpic  -O3 -g0 -Wall -pipe -pedantic -std=gnu99  -c setwidth.c -o setwidth.o
ccache gcc-4.8 -shared -o setwidth.so setwidth.o -L/usr/lib/R/lib -lR
installing to /usr/local/lib/R/site-library/setwidth/libs
** R
** preparing package for lazy loading
** help
*** installing help indices
** building package indices
** testing if installed package can be loaded
* DONE (setwidth)

The downloaded source packages are in
    ‘/tmp/downloaded_packages’
edd@max:~$ 

Here install.r is a script from my littler package; the compiler setting is my default of wrapping via the (awesome) ccache tool.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top