我正在尝试在R 3.6.0中安装“ ggtext”软件包,该软件包依赖于另一个名为“ gridtext”的软件包。运行install.packages(“ ggtext”)后,出现错误:
grid-renderer.h:61:94: error: no matching function for call to ‘Rcpp::Vector<10, Rcpp::PreserveStorage>::Vector(int, bool&, const GraphicsContext&)’
尝试从github安装会导致相同的问题。我正在尝试在运行CentOS Linux版本7.7.1908的服务器中执行此操作。
更详细的错误消息:
g++ -m64 -std=gnu++11 -I"/usr/include/R" -DNDEBUG -I"/home/myuser/R/x86_64-redhat-linux-gnu-library/3.6/Rcpp/include" -I"/home/myuser/R/x86_64-redhat-linux-gnu-library/3.6/testthat/include" -I/usr/local
/include -fpic -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -c RcppExports.cpp -o RcppExports.
o
In file included from gridtext_types.h:12:0,
from RcppExports.cpp:4:
grid-renderer.h: In member function ‘void GridRenderer::raster(Rcpp::RObject, Length, Length, Length, Length, bool, const GraphicsContext&)’:
grid-renderer.h:61:94: error: no matching function for call to ‘Rcpp::Vector<10, Rcpp::PreserveStorage>::Vector(int, bool&, const GraphicsContext&)’
NumericVector(1, width), NumericVector(1, height), LogicalVector(1, interpolate, gp)
编辑:
尝试install.packages("gridtext", dep = TRUE)
会导致以下错误:
Package cairo was not found in the pkg-config search path.
Perhaps you should add the directory containing `cairo.pc'
to the PKG_CONFIG_PATH environment variable
No package 'cairo' found
Package cairo was not found in the pkg-config search path.
Perhaps you should add the directory containing `cairo.pc'
to the PKG_CONFIG_PATH environment variable
No package 'cairo' found
Using PKG_CFLAGS=
Using PKG_LIBS=-lcairo -lfreetype
-----------------------------[ ANTICONF ]-------------------------------
Configuration failed to find Cairo or Freetype2. Try installing:
* deb: libcairo2-dev (Debian, Ubuntu)
* rpm: cairo-devel (Fedora, CentOS, RHEL)
* csw: libcairo_dev (Solaris)
* brew: cairo (OSX)
If cairo freetype2 is already installed, check that 'pkg-config' is in your
PATH and PKG_CONFIG_PATH contains a cairo freetype2.pc file. If pkg-config
is unavailable you can set INCLUDE_DIR and LIB_DIR manually via:
R CMD INSTALL --configure-vars='INCLUDE_DIR=... LIB_DIR=...'
---------------------------[ ERROR MESSAGE ]----------------------------
src/tests/sysdeps.c:1:10: fatal error: cairo-ft.h: No such file or directory
#include <cairo-ft.h>
^~~~~~~~~~~~
compilation terminated.
------------------------------------------------------------------------
ERROR: configuration failed for package ‘gdtools’
* removing ‘/home/miguel/R/x86_64-redhat-linux-gnu-library/3.6/gdtools’
ERROR: dependency ‘gdtools’ is not available for package ‘vdiffr’
* removing ‘/home/miguel/R/x86_64-redhat-linux-gnu-library/3.6/vdiffr’
The downloaded source packages are in
‘/tmp/RtmpszdI5c/downloaded_packages’
Warning messages:
1: In install.packages("gridtext", dep = TRUE) :
installation of package ‘gridtext’ had non-zero exit status
2: In install.packages("gridtext", dep = TRUE) :
installation of package ‘gdtools’ had non-zero exit status
3: In install.packages("gridtext", dep = TRUE) :
installation of package ‘vdiffr’ had non-zero exit status
> install.packages('ggext', dep=TRUE)
编辑
完成sudo yum install cairo-devel
g++ -m64 -std=gnu++11 -I"/usr/include/R" -DNDEBUG -I"/home/miguel/R/x86_64-redh
at-linux-gnu-library/3.6/Rcpp/include" -I"/home/miguel/R/x86_64-redhat-linux-gnu
-library/3.6/testthat/include" -I/usr/local/include -fpic -O2 -g -pipe -Wall -
Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-
size=4 -grecord-gcc-switches -m64 -mtune=generic -c RcppExports.cpp -o RcppEx
ports.o
In file included from gridtext_types.h:12:0,
from RcppExports.cpp:4:
grid-renderer.h: In member function ‘void GridRenderer::raster(Rcpp::RObject, Le
ngth, Length, Length, Length, bool, const GraphicsContext&)’:
grid-renderer.h:61:94: error: no matching function for call to ‘Rcpp::Vector<10,
Rcpp::PreserveStorage>::Vector(int, bool&, const GraphicsContext&)’
icVector(1, width), NumericVector(1, height), LogicalVector(1, interpolate, gp)
答案 0 :(得分:0)
你的g++版本太低,不支持c++11,https://github.com/wilkelab/gridtext/issues/7#issuecomment-646808225已经指出。
使用以下命令:
sudo yum install centos-release-scl
sudo yum install devtoolset-9
# If you use your non-root account to install packages,
# remove the sudo and change /root to /home/your_id in the following command
sudo mkdir -p /root/.R
sudo vim /root/.R/Makevars
在打开的文件中添加内容并保存:
CXX11=/opt/rh/devtoolset-9/root/usr/bin/g++ -std=c++11
重新安装软件包,您将看到g++
已更改为/opt/rh/devtoolset-9/root/usr/bin/g++
> install.packages("gridtext")
Installing package into ‘/usr/lib64/R/library’
(as ‘lib’ is unspecified)
trying URL 'http://cran.rstudio.com/src/contrib/gridtext_0.1.4.tar.gz'
Content type 'application/x-gzip' length 234461 bytes (228 KB)
==================================================
downloaded 228 KB
* installing *source* package ‘gridtext’ ...
** package ‘gridtext’ successfully unpacked and MD5 sums checked
** using staged installation
** libs
/opt/rh/devtoolset-9/root/usr/bin/g++ -std=c++11 -std=gnu++11 -I"/usr/include/R" -DNDEBUG -I"/usr/lib64/R/library/Rcpp/include" -I/usr/local/include -fpic -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -c RcppExports.cpp -o RcppExports.o