简体   繁体   English

R在install.packages(“RGtk2”)中:致命错误:找不到'gdk / gdkx.h'文件

[英]R In install.packages(“RGtk2”) : fatal error: 'gdk/gdkx.h' file not found

when I install.packages("RGtk2") in R this I get this problem: 当我在R中安装.packages(“RGtk2”)时,我遇到了这个问题:

    fatal error: 'gdk/gdkx.h' file not found
#include <gdk/gdkx.h>
         ^
1 error generated.
make: *** [Rgtk.o] Error 1
ERROR: compilation failed for package ‘RGtk2’
* removing ‘/usr/local/lib/R/3.4/site-library/RGtk2’
* restoring previous ‘/usr/local/lib/R/3.4/site-library/RGtk2’

I install GTK using brew in macOS Sierra 10.12.3 我在macOS Sierra 10.12.3中使用brew安装GTK

According to the INSTALL documentation , you have to have Gtk libraries installed first: 根据INSTALL文档 ,您必须先安装Gtk库:

In all cases (ie Unix or Windows, source or binary), you will need to have the appropriate Gtk libraries. 在所有情况下(即Unix或Windows,源代码或二进制代码),您都需要拥有适当的Gtk库。

For Windows, you can download the GTK Developer's Pack from http://gladewin32.sourceforge.net/ 对于Windows,您可以从http://gladewin32.sourceforge.net/下载GTK Developer's Pack。

For Unix, you can fetch the source files for the different libraries from ftp://ftp.gtk.org/pub/gtk/v2.8/ 对于Unix,您可以从ftp://ftp.gtk.org/pub/gtk/v2.8/获取不同库的源文件

GTK makes extensive use of other libraries and particular versions of these dependant libraries. GTK广泛使用其他库和这些依赖库的特定版本。 As a result, installing GTK (under Unix) can be a time consuming and apparently indirect process that involves installing numerous sub-libraries. 因此,安装GTK(在Unix下)可能是一个耗时且显然是间接的过程,涉及安装许多子库。

I suspect HomeBrew's Gtk might not be installed on your system properly. 我怀疑HomeBrew的Gtk可能没有正确安装在你的系统上。

Further research reveals similar problems, as well as suggested troubleshooting to get Gtk and RGtk2 to work together. 进一步的研究揭示了类似的问题,并建议进行故障排除以使Gtk和RGtk2协同工作。

The installation of RGtk2 can be much easier now. 现在可以更轻松地安装RGtk2 First install Homebrew , then in R: 首先安装Homebrew ,然后在R中:

system('brew install gtk+')
install.packages(
  'RGtk2', type = 'mac.binary.el-capitan', repos = 'https://macos.rbind.org'
)

If you do not prefer using the repository https://macos.rbind.org (which was created by me) to install the pre-built binary package, you may just install RGtk2 from source: 如果您不喜欢使用存储库https://macos.rbind.org (由我创建)来安装预构建的二进制包,您可以从源代码安装RGtk2

system('brew install gtk+')
install.packages('RGtk2', type = 'source')

In case anyone is curious about the technical details, the error "'gdk/gdkx.h' file not found" has been fixed in this commit in the RGtk2 repo on Github. 如果有人对技术细节感到好奇,那么错误“'gdk / gdkx.h'文件未找到”已在Github上的RGtk2 repo中的此提交中得到修复。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM