英特尔编译器 - 无法在R中安装需要eventloop.h的软件包

时间:2014-02-28 20:56:02

标签: r compiler-errors icc intel-mkl

好像我无法在R中安装任何需要编译任何文件的软件包。 eventloop.h

我使用英特尔编译器自定义安装R并链接到英特尔MKL BLAS库。

以下是我得到的具体错误:

> 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

让我知道您可能需要的任何其他信息,以帮助我解决此问题。

编辑:

我尝试添加

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

到我的〜/ .R / Makevars文件,因为在fd_set中定义/sys/select.h没有运气,任何人都有任何想法???

编辑:

所以每个包都不会出现这个问题,只有需要某些R头的包。到目前为止,我只遇到某个作者编写的软件包的问题(R与VIM集成所需的所有软件包,http://www.lepem.ufc.br/jaa/vim-r-plugin.html)有没有人有任何想法?

编辑:

似乎是一个编译器问题:

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

然而

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

没有

2 个答案:

答案 0 :(得分:2)

让我们稍微回顾一下:

  1. Ubuntu与R一起使用极为广泛。

  2. 您可以安装prebuilt current binary from CRAN

  3. 然后您可以添加MKL,因为它们的标准接口可以互换BLAS。 (这经常被误解;请参阅我的gcbd vignette了解一些细节)

  4. 通过更常见的设置,您可以轻松编译软件包,或者获得预先构建的软件包。

  5. 然后,您可以更密切地研究您的英特尔®ICc设置。

  6. 目前它已经坏了,你可以保留两件。

    编辑:为了让它更简单,在标准的Ubuntu系统上使用Ubuntu二进制包关闭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:~$ 
    

    此处install.r是我littler包中的脚本;编译器设置是我通过(awesome)ccache工具包装的默认设置。

答案 1 :(得分:1)

不确定这是否是一个合适的解决方案,但是当我偷看/usr/local/lib/R/include/R_ext/eventloop.h时,我在include语句中看到了以下内容:

#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

正如您所看到的,sys / select.h仅包含在一些变量HAVE_SYS_SELECT_H中。我拿出了这个条件声明:

#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

成功编译(和安装)包。如果有人对此特定变量HAVE_SYS_SELECT_H未正确定义的原因有任何了解,请告诉我。