【问题标题】:Cannot install R with cairo无法使用 cairo 安装 R
【发布时间】:2017-05-23 18:50:07
【问题描述】:

我正在从源代码安装 R:

cd R-3.2.2
./configure --prefix=$( pwd ) --with-cairo=yes --with-readline=no --with-libpng=yes --with-x=no

我已经从源代码安装了 cairo (v1.14.8) 和 pango (v1.40.6)(安装时没有任何错误)。但是 R 没有配置 cairo:

R is now configured for x86_64-pc-linux-gnu

  Source directory:          .
  Installation directory:    /athena/elementolab/scratch/chm2059/from_dat02/chm2059/lib/R-3.2.2

  C compiler:                gcc -std=gnu99  -I/athena/elementolab/scratch/chm2059/from_dat02/chm2059/lib/bzip2-1.0.6/include/packages/include
  Fortran 77 compiler:       gfortran  -g -O2

  C++ compiler:              g++  -g -O2
  C++ 11 compiler:           g++  -std=c++11 -g -O2
  Fortran 90/95 compiler:    gfortran -g -O2
  Obj-C compiler:         

  Interfaces supported:      
  External libraries:        zlib, PCRE, curl
  Additional capabilities:   NLS
  Options enabled:           shared BLAS, R profiling

  Capabilities skipped:      PNG, JPEG, TIFF, cairo, ICU
  Options not enabled:       memory profiling

  Recommended packages:      yes

configure: WARNING: you cannot build info or HTML versions of the R manuals
configure: WARNING: you cannot build PDF versions of the R manuals
configure: WARNING: you cannot build PDF versions of vignettes and help pages

我在配置时看到这些行:

checking for X... disabled
using X11 ... no
checking whether pkg-config knows about cairo and pango... yes
checking whether cairo including pango is >= 1.2 and works... no

有什么想法吗?

【问题讨论】:

标签: r


【解决方案1】:

我在 Why do Greek letters fail to render in R's (v4) PDF output? 中遇到了同样的问题 - 这就是我为 R 4.0.3 修复它的方法:

打开configure 脚本,找到这个:

$as_echo_n "checking whether cairo including pango is >= 1.2 and works... " >&6; }
if ${r_cv_cairo_works+:} false; then :
  $as_echo_n "(cached) " >&6
else
  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h.  */

#include <pango/pango.h>
#include <pango/pangocairo.h>
#include <cairo-xlib.h>
#if CAIRO_VERSION  < 10200
#error cairo version >= 1.2 required
#endif
int main(void) {
    cairo_t  *CC = NULL; // silence picky compilers
    cairo_arc(CC, 0.0, 0.0, 1.0, 0.0, 6.28);
    pango_cairo_create_layout(CC);
    pango_font_description_new();
    return 0;
 }

_ACEOF

将此核心代码部分复制到某个test.c 文件中:

#include <pango/pango.h>
#include <pango/pangocairo.h>
#include <cairo-xlib.h>
#if CAIRO_VERSION  < 10200
#error cairo version >= 1.2 required
#endif
int main(void) {
    cairo_t  *CC = NULL; // silence picky compilers
    cairo_arc(CC, 0.0, 0.0, 1.0, 0.0, 6.28);
    pango_cairo_create_layout(CC);
    pango_font_description_new();
    return 0;
 }

然后运行cc test.c $(pkg-config --cflags --libs pangocairo)。这可能会为您提供有关configure 测试失败原因的更多信息。也可以使用

cc test.c $(pkg-config --cflags --libs pangocairo) --verbose

cc test.c $(pkg-config --cflags --libs pangocairo) -Wl,--verbose

获取更多信息。

就我而言,我在安装了一些缺少的软件包后终于得到了这个:

/usr/lib64/gcc/x86_64-suse-linux/7/../../../../x86_64-suse-linux/bin/ld: cannot find -lharfbuzz
collect2: error: ld returned 1 exit status

原因是/usr/lib64 中的链接断开:

修复后,一切正常:缺少root权限,我用过

mkdir ~/lib
cp /usr/lib64/libharfbuzz.so.0 ~/lib/libharfbuzz.so
export LIBRARY_PATH=~/lib

然后,cc test.c $(pkg-config --cflags --libs pangocairo) 完成,使用 pango 和 cairo 进行配置也正常。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-02-17
    • 1970-01-01
    • 2023-03-10
    • 1970-01-01
    相关资源
    最近更新 更多