我正在从源代码安装 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
有什么想法吗?
最佳答案
我在 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
一旦修复,一切正常:缺少 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 进行配置也能正常工作。
关于r - 无法使用 cairo 安装 R,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44142825/