[英]Compile R with Cairo support without X11
I'm trying to compile R 3.1.1 from source with cairo support enabled. 我正在尝试从启用cairo支持的源代码编译R 3.1.1。 I want this because I'm trying to run R on a server which does not have a graphical environment (hence no X11), but still output PNG's.
我想要这个,因为我试图在没有图形环境的服务器上运行R(因此没有X11),但仍然输出PNG。
I tried to configure R with 我试着用R配置
./configure --with-x=no --with-cairo=yes --with-libpng=yes --enable-R-shlib --prefix=$HOME
Doing this produces an R binary with no png or cairo support (as evidenced by capabilities()
). 这样做会生成一个没有png或cairo支持的R二进制文件(如
capabilities()
)。 In config.log
, there is the following. 在
config.log
,有以下内容。
configure:31563: checking for X
configure:31749: result: disabled
configure:32420: result: using X11 ... no
configure:32530: checking whether pkg-config knows about cairo and pango
configure:32542: result: yes
configure:32576: checking whether cairo including pango is >= 1.2 and works
configure:32599: gcc -std=gnu99 -o conftest -g -O2 -fpic -I/usr/local/include -pthread -I/home/rmccloskey/include/pango-1.0 -I/home/rmccloskey/include/cairo -I/home/rmccl
oskey/include/glib-2.0 -I/home/rmccloskey/lib/glib-2.0/include -I/home/rmccloskey/include/pixman-1 -I/usr/include/freetype2 -I/home/rmccloskey/include/freetype2 -I/home/rmc
closkey/include/libpng16 -L/usr/local/lib64 conftest.c -lrt -ldl -lm -L/home/rmccloskey/lib -lpangocairo-1.0 -lpango-1.0 -lgobject-2.0 -lglib-2.0 -lpng16 -lz -lcairo >
&5
conftest.c:232:24: fatal error: cairo-xlib.h: No such file or directory
#include <cairo-xlib.h>
^
compilation terminated.
As you can see, configure knows about cairo and pango, and it also knows that I'm not using X11. 如您所见,configure知道cairo和pango,它也知道我没有使用X11。 But it still tries to compile a file requiring
cairo-xlib.h
? 但是它仍然试图编译一个需要
cairo-xlib.h
的文件? What can I do here? 我能在这做什么?
I've been able to make this work with CentOS-6.5 and R-3.1.2. 我已经能够使用CentOS-6.5和R-3.1.2完成这项工作。 I had to yum install cairo and pango first.
我不得不首先安装cairo和pango。 Here is my configure command:
这是我的configure命令:
./configure --with-recommended-packages=no --without-x --with-cairo --with-libpng --with-libtiff --with-jpeglib --enable-R-shlib ./configure --with-recommended-packages = no --without-x --with-cairo --with-libpng --with-libtiff --with-jpeglib --enable-R-shlib
In the most narrow sense, Cairo appears to require x11 headers. 从狭义上讲,开罗似乎需要x11标头。
In a wider sense, look into the various answers detailing use of the xvfb
virtual x11 server -- they allow you headless use. 从更广泛的意义上讲,查看详细介绍
xvfb
虚拟x11服务器使用的各种答案 - 它们允许您无头使用。
Also, you could try building without x11, png, cairo -- and then use one of the two cairo packages from CRAN to create graphs. 此外,您可以尝试在没有x11,png,cairo的情况下构建 - 然后使用CRAN的两个cairo包中的一个来创建图形。 In Debian/Ubuntu we also have at least the cairoDevice package pre-build for you.
在Debian / Ubuntu中,我们至少还为您预先构建了cairoDevice包。
I have the exact some problem. 我有一些确切的问题。 I solved this by using the very hackish way below.
我用下面非常强硬的方式解决了这个问题。
In the Rxyz src directory, edit the configure file. 在Rxyz src目录中,编辑配置文件。 There is the line:
有一条线:
#include <cairo-xlib.h>
I simply removed this line. 我只是删除了这一行。 And then run this file and make.
然后运行此文件并制作。 Everything works for me.
一切都适合我。 My cairo is compiled with out x11 support.
我的cairo编译时支持x11。 Because I am on a shared RHEL6 box.
因为我在共享的RHEL6盒子上。 I do everything without root.
我做任何事都没有根。 The purpose I do this is to make R work with Jupyter notebook.
我这样做的目的是让R与Jupyter笔记本一起工作。 In addition to this, I also need to add
options(bitmapType='cairo')
in $HOME/.Rprofile
. 除此之外,我还需要在
$HOME/.Rprofile
添加options(bitmapType='cairo')
。 This Link is very helpful. 此链接非常有用。
By doing all these hacks, everything works for me now. 通过做所有这些黑客攻击,现在一切都适合我。 :)
:)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.