6

when I install.packages("RGtk2") in R this I get this problem:

    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

Green Baylee
  • 117
  • 3
  • 8

2 Answers2

3

According to the INSTALL documentation, you have to have Gtk libraries installed first:

In all cases (i.e. Unix or Windows, source or binary), you will need to have the appropriate Gtk libraries.

For Windows, you can download the GTK Developer's Pack from http://gladewin32.sourceforge.net/

For Unix, you can fetch the source files for the different libraries from ftp://ftp.gtk.org/pub/gtk/v2.8/

GTK makes extensive use of other libraries and particular versions of these dependant libraries. As a result, installing GTK (under Unix) can be a time consuming and apparently indirect process that involves installing numerous sub-libraries.

I suspect HomeBrew's Gtk might not be installed on your system properly.

Further research reveals similar problems, as well as suggested troubleshooting to get Gtk and RGtk2 to work together.

hongsy
  • 1,498
  • 1
  • 27
  • 39
0

The installation of RGtk2 can be much easier now. First install Homebrew, then in 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:

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.

Yihui Xie
  • 28,913
  • 23
  • 193
  • 419