RGtk2 installation fails on Windows 11

OS: Windows 11
R version: 4.1.2


I'm starting a course on Data Science using R/RStudio and we need to install rattle package. It happens that to execute rattle I need to install RGtk2 but it was removed from CRAN repository.

I tried to install the package using Rtools4 and then this command:

install.packages("https://cran.r-project.org/src/contrib/Archive/RGtk2/RGtk2_2.20.36.3.tar.gz",repos = NULL)

This is the outcome I had:

  • installing source package 'RGtk2' ...
    ** package 'RGtk2' successfully unpacked and MD5 sums checked
    ** using staged installation
    ** libs
    "C:/rtools40/mingw64/bin/"gcc -I"C:/PROGRA~1/R/R-4.1.2/include" -DNDEBUG -D_R_=1 -DUSE_R=1 -mms-bitfields -I/include/gtk-2.0 -I/lib/gtk-2.0/include -I/include/atk-1.0 -I/include/cairo -I/include/pango-1.0 -I/include/glib-2.0 -I/lib/glib-2.0/include -I/include/libxml2 -I/include/gdk-pixbuf-2.0 -I/include -I. -DR_LEGACY_S_DEFS=1 -O2 -Wall -std=gnu99 -mfpmath=sse -msse2 -mstackrealign -c RGtkDataFrame.c -o RGtkDataFrame.o
    In file included from ./RGtk2/atk.h:4,
    from RGtk2/gtk.h:4,
    from RGtkDataFrame.h:1,
    from RGtkDataFrame.c:1:
    ./RGtk2/gobject.h:7:10: fatal error: glib.h: No such file or directory
    #include <glib.h>
    compilation terminated.
    make: *** [C:/PROGRA~1/R/R-4.1.2/etc/x64/Makeconf:238: RGtkDataFrame.o] Error 1
    ERROR: compilation failed for package 'RGtk2'
  • removing 'C:/Users/EduVm/Documents/R/win-library/4.1/RGtk2'
    Warning in install.packages :
    installation of package ‘C:/Users/EduVm/AppData/Local/Temp/Rtmp8epO4G/downloaded_packages/RGtk2_2.20.36.3.tar.gz’ had non-zero exit status

I tried installing different versions of RGtk2 with the same results. Any ideas why compilation is failed?

I found a similar issue in this topic, but it seems the installation worked by itself: https://forum.posit.co/t/rgtk2-update-fails-on-windows-10/117977/2

The compiler is looking for a system library which is not installed in your system, glib, which is required by Gtk. Look into manually installing Gtk and its dependencies on Windows.

Thank you,

How would I know if I installed Gtk correctly on my Windows? I followed these instructions until Step 2 and I think it would work: The GTK Project - A free and open-source cross-platform widget toolkit

RStudio is giving me the same output when I try to install RGtk2 though.

Sorry but I have never used anything that required Gtk, that is mostly used to provide graphical user interfaces and R is supposed to be used mainly trough the console.

If R doesn't recognize your Gtk installation maybe you need manually added to the PATH but I'm just guessing, I have no practical experience with this.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.