我需要安装svglite,但是出现了一个错误,说我首先需要gdtools,所以我尝试安装gdtools并得到以下错误:
> install.packages("gdtools", lib="/usr/local/lib/R/3.4/site-library")
trying URL 'https://cran.rstudio.com/src/contrib/gdtools_0.1.4.tar.gz'
Content type 'application/x-gzip' length 33931 bytes (33 KB)
==================================================
downloaded 33 KB
* installing *source* package ‘gdtools’ ...
** package ‘gdtools’ successfully unpacked and MD5 sums checked
Using PKG_CFLAGS=-I/usr/local/opt/cairo/include/cairo
Using PKG_LIBS=-L/usr/local/opt/cairo/lib -lcairo
** libs
clang++ -I/usr/local/Cellar/r/3.4.1_1/lib/R/include -DNDEBUG -I/usr/local/opt/cairo/include/cairo -I../inst/include/ -I"/usr/local/lib/R/3.4/site-library/Rcpp/include" -I/usr/local/opt/gettext/include -I/usr/local/opt/readline/include -I/usr/local/include -fPIC -g -O2 -c CairoContext.cpp -o CairoContext.o
In file included from CairoContext.cpp:7:
/usr/local/opt/cairo/include/cairo/cairo-ft.h:46:10: fatal error: 'ft2build.h' file not found
#include <ft2build.h>
^
1 error generated.
make: *** [CairoContext.o] Error 1
ERROR: compilation failed for package ‘gdtools’
* removing ‘/usr/local/lib/R/3.4/site-library/gdtools’
Warning in install.packages :
installation of package ‘gdtools’ had non-zero exit status
The downloaded source packages are in
‘/private/var/folders/2c/2dtnf2fs5z7cy45v5gt32n0m0000gn/T/Rtmpj7APMT/downloaded_packages’
有人可以帮我吗?
答案 0 :(得分:2)
我遇到了同样的问题,以下解决方案对我有用:
brew install pkg-config
brew install cairo
然后我能够成功安装gdtools
和svglite
R包。
答案 1 :(得分:1)
类似于@bogenton的回答,解决方案是同时安装cairo和pkgconfig。
对于其他使用conda而不是brew的人:
conda install -c anaconda cairo
conda install -c anaconda pkgconfig
答案 2 :(得分:0)
即使通过Homebrew安装了cairo
和pkg-config
,我也遇到了同样的问题,而PKG_CONFIG_PATH的解决方案都不适合我。
但是使用devtools
安装GitHub版本可以达到目的:
devtools::install_github('davidgohel/gdtools')
devtools::install_github("r-lib/svglite")
devtools
必须有一个正确找到路径和标志的原因,也许有人可以解释它。
此外,如果要保持GitHub版本更新,可以使用dtupdate
R软件包。
答案 3 :(得分:0)
我有类似的问题。 我安装了开罗 sudo apt-get install libcairo2-dev
然后将gdtools毫无问题地安装在R中