错误:安装包 'rgl' 时出现非零退出状态

6

我想使用plot 3D,所以我尝试下载rgl。但是每当我尝试安装它时,我都会在rgl包安装中遇到错误。您能否给我一些建议?

install.packages("rgl", dependencies=TRUE)
     Installing package into ‘/root/R/x86_64-unknown-linux-gnu-library/3.2’
     (as ‘lib’ is unspecified)
     --- Please select a CRAN mirror for use in this session ---
trying URL 'http://cran.skazkaforyou.com/src/contrib/rgl_0.95.1247.tar.gz'
Content type 'application/x-gzip' length 2014799 bytes (1.9 MB)
==================================================
downloaded 1.9 MB

* installing *source* package ‘rgl’ ...
** package ‘rgl’ successfully unpacked and MD5 sums checked
checking for gcc... gcc -std=gnu99
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc -std=gnu99 accepts -g... yes
checking for gcc -std=gnu99 option to accept ISO C89... none needed
checking how to run the C preprocessor... gcc -std=gnu99 -E
checking for gcc... (cached) gcc -std=gnu99
checking whether we are using the GNU C compiler... (cached) yes
checking whether gcc -std=gnu99 accepts -g... (cached) yes
checking for gcc -std=gnu99 option to accept ISO C89... (cached) none needed
checking whether __attribute__((visibility())) is supported... yes
checking whether gcc -std=gnu99 accepts -fvisibility... yes
checking whether  accepts -fvisibility... no
checking for libpng-config... yes
configure: using libpng-config
configure: using libpng dynamic linkage
checking for X... libraries , headers 
checking GL/gl.h usability... no
checking GL/gl.h presence... no
checking for GL/gl.h... no
checking GL/glu.h usability... no
checking GL/glu.h presence... no
checking for GL/glu.h... no
configure: error: missing required header GL/gl.h
ERROR: configuration failed for package ‘rgl’
* removing ‘/root/R/x86_64-unknown-linux-gnu-library/3.2/rgl’

The downloaded source packages are in
‘/tmp/RtmpP1KuPN/downloaded_packages’
Warning message:
In install.packages("rgl", dependencies = TRUE) :
      installation of package ‘rgl’ had non-zero exit status

1
查看这一行 checking GL/gl.h usability... no。并且浏览此网页,其中明确说明 *SystemRequirements: OpenGL, GLU Library, zlib (可选), libpng (>=1.2.9,可选), FreeType (可选) * 如果我没记错,在Ubuntu上,您需要 libglu1-mesa-devmesa-common-dev - user3710546
1个回答

12

rgl的安装需要预先安装一些系统库。包rgl索引页面提供了一些重要信息:

SystemRequirements: OpenGL, GLU Library, zlib (optional), libpng (>=1.2.9, optional), FreeType (optional)

一旦我们知道OpenGLGLU库是必需的,我们就必须检查它们是否已经存在于系统中。一种方法是读取rgl安装日志。 如果出现以下行:

checking GL/gl.h usability... no
checking GL/gl.h presence... no
checking for GL/gl.h... no
checking GL/glu.h usability... no
checking GL/glu.h presence... no
checking for GL/glu.h... no
configure: error: missing required header GL/gl.h

这意味着缺少GLU库,必须安装它。 例如,在Ubuntu上,我们可以运行:

sudo apt-get install libglu1-mesa-dev

在RedHat中,它应该是:
yum install Mesa-devel

这将安装GLU库的头文件。然后我们可以再次运行:

install.packages("rgl", dependencies = TRUE)

1
在我的情况下[Ubuntu 16.04],问题出在freetype上(似乎它并不是那么可选),所以我在执行sudo apt install libfreetype6-dev之后成功了。 - FairMiles

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接