configure: error: Cannot find cairo.h! Please install cairo (http://www.cairographics.org/) and/or set CAIRO_CFLAGS/LIBS correspondingly

1、问题

install.packages('Cairo', repos='https://mirror.lzu.edu.cn/CRAN/')
…………
…………
configure: error: Cannot find cairo.h! Please install cairo (http://www.cairographics.org/) and/or set CAIRO_CFLAGS/LIBS correspondingly.
ERROR: configuration failed for package ‘Cairo’
* removing ‘/home/software/R/lib64/R/library/Cairo’

The downloaded source packages are in/tmp/RtmpaXjXEm/downloaded_packages’
Updating HTML index of packages in '.Library'
Making 'packages.html' ... done
Warning message:
In install.packages("Cairo", repos = "https://mirror.lzu.edu.cn/CRAN/") :
  installation of package ‘Cairo’ had non-zero exit status

2、解决方法

> quit()
Save workspace image? [y/n/c]: n

3、

[root@centos8 ~]# yum  install cairo* libxt*
…………
…………
Upgraded:
  freetype-2.9.1-4.el8_3.1.x86_64             iptables-1.8.4-15.el8_3.3.x86_64       iptables-ebtables-1.8.4-15.el8_3.3.x86_64
  iptables-libs-1.8.4-15.el8_3.3.x86_64

Installed:
  cairo-devel-1.15.12-3.el8.x86_64           cairo-gobject-devel-1.15.12-3.el8.x86_64       expat-devel-2.2.5-4.el8.x86_64
  fontconfig-devel-2.13.1-3.el8.x86_64       freetype-devel-2.9.1-4.el8_3.1.x86_64          glib2-devel-2.56.4-8.el8.x86_64
  libXext-devel-1.3.4-1.el8.x86_64           libXrender-devel-0.9.10-7.el8.x86_64           libpng-devel-2:1.6.34-5.el8.x86_64
  libuuid-devel-2.32.1-24.el8.x86_64         pcre-cpp-8.42-4.el8.x86_64                     pcre-devel-8.42-4.el8.x86_64
  pcre-utf16-8.42-4.el8.x86_64               pcre-utf32-8.42-4.el8.x86_64                   pixman-devel-0.38.4-1.el8.x86_64

Complete!

4、

[root@centos8 ~]# R

R version 4.0.3 (2020-10-10) -- "Bunny-Wunnies Freak Out"
Copyright (C) 2020 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

  Natural language support but running in an English locale

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

>

5、

> install.packages('Cairo', repos='https://mirror.lzu.edu.cn/CRAN/')
…………
…………
** testing if installed package keeps a record of temporary installation path
* DONE (Cairo)

The downloaded source packages are in/tmp/RtmpM2ctTJ/downloaded_packages’
Updating HTML index of packages in '.Library'
Making 'packages.html' ... done

6、测试

> library(Cairo)
>
原文地址:https://www.cnblogs.com/liujiaxin2018/p/14361394.html