I'm trying to get RGtk to build on Windows, so that I can be confident that my package Retistruct will be usable in the future for Windows users (see this issue davidcsterratt/retistruct#52).
I was wondering if it would be possible to get RGtk to build using only the libraries available in Rtools, which appear to include all the required dependencies. It would then be possible (I suppose) to get new versions compiled using the win_builder service, which might assist with getting RGtk back on CRAN.
I've been experimenting with setting up the PKG_CPPLFAGS and PKG_LIBS in Makevars.win using the output from the pkg-config that I installed into the Rtools mingw32 system using pacman:
# PKG_CONFIG_PATH=/x86_64-w64-mingw32.static.posix/lib/pkgconfig/:$PKG_CONFIG_PATH
# pkg-config.exe --static --cflags gtk+-2.0
PKG_CPPFLAGS = -I/usr/lib/mxe/usr/x86_64-w64-mingw32.static.posix/include/gtk-2.0 -I/usr/lib/mxe/usr/x86_64-w64-mingw32.static.posix/lib/gtk-2.0/include -I/usr/lib/mxe/usr/x86_64-w64-mingw32.static.posix/include/libpng16 -I/usr/lib/mxe/usr/x86_64-w64-mingw32.static.posix/include/atk-1.0 -I/usr/lib/mxe/usr/x86_64-w64-mingw32.static.posix/include/pango-1.0 -I/usr/lib/mxe/usr/x86_64-w64-mingw32.static.posix/include/cairo -I/usr/lib/mxe/usr/x86_64-w64-mingw32.static.posix/include -I/usr/lib/mxe/usr/x86_64-w64-mingw32.static.posix/include/gdk-pixbuf-2.0 -DPCRE_STATIC -I/usr/lib/mxe/usr/x86_64-w64-mingw32.static.posix/include/harfbuzz -I/usr/lib/mxe/usr/x86_64-w64-mingw32.static.posix/include/fribidi -DFRIBIDI_LIB_STATIC -I/usr/lib/mxe/usr/x86_64-w64-mingw32.static.posix/include/freetype2 -I/usr/lib/mxe/usr/x86_64-w64-mingw32.static.posix/include/glib-2.0 -I/usr/lib/mxe/usr/x86_64-w64-mingw32.static.posix/lib/glib-2.0/include -I/usr/lib/mxe/usr/x86_64-w64-mingw32.static.posix/include/pixman-1 -pthread -mms-bitfields -D_R_=1 -DUSE_R=1 -I. -I../inst/include
# pkg-config.exe --static --libs gtk+-2.0
PKG_LIBS=-L/usr/lib/mxe/usr/x86_64-w64-mingw32.static.posix/lib -lgdk-win32-2.0 -lgtk-win32-2.0 -limm32 -lshell32 -L/usr/lib/mxe/usr/x86_64-w64-mingw32.static.posix/lib/../lib -lws2_32 -lws2_32 -lpangocairo-1.0 -lws2_32 -lws2_32 -lws2_32 -lws2_32 -lws2_32 -latk-1.0 -lws2_32 -lexpat -lwebp -lzstd -llzma -ljpeg -luuid -lz -lwinspool -lcomctl32 -lcomdlg32 -lpangoft2-1.0 -ltiff -lwebp -lzstd -llzma -lgdk_pixbuf-2.0 -ljpeg -lpangowin32-1.0 -lgmodule-2.0 -ldl -lffi -lpango-1.0 -lfribidi -L/usr/lib/mxe/usr/x86_64-w64-mingw32.static.posix/lib -lexpat -lcairo -lz -lmsimg32 -lgdi32 -lpixman-1 -lz -lz -lmsimg32 -lgdi32 -lpixman-1 -lgio-2.0 -ldl -ldnsapi -liphlpapi -lz -lole32 -lshlwapi -luuid -L/usr/lib/mxe/usr/x86_64-w64-mingw32.static.posix/lib -lpixman-1 -lfontconfig -L/usr/lib/mxe/usr/x86_64-w64-mingw32.static.posix/lib -lexpat -lharfbuzz -lfreetype -lbz2 -lpng16 -lz -lharfbuzz_too -lfreetype_too -lole32 -lshlwapi -lpcre -lgobject-2.0 -lglib-2.0 -luuid -lintl -liconv -pthread -lws2_32 -lwinmm -lm -lole32 -lshlwapi -luuid
The source files compile to .o files OK, but then there are linking issues - see truncated output below and the full output (attached). I fear I may be on a fool's errand, but any advice on what do to next would be much appreciated... I am reasonably experienced in building packages on Linux, but not on Windows.
gcc -shared -s -static-libgcc -o RGtk2.dll tmp.def RGtkDataFrame.o Rgtk.o atkAccessors.o atkClasses.o atkConversion.o atkFuncs.o atkManuals.o atkUserFuncs.o cairo-enums.o cairoAccessors.o cairoConversion.o cairoFuncs.o cairoManuals.o cairoUserFuncs.o classes.o connections.o conversion.o eventLoop.o gdkAccessors.o gdkClasses.o gdkConversion.o gdkFuncs.o gdkManuals.o gdkUserFuncs.o gioAccessors.o gioClasses.o gioConversion.o gioFuncs.o gioManuals.o gioUserFuncs.o glib.o gobject.o gtkAccessors.o gtkClasses.o gtkConversion.o gtkFuncs.o gtkManuals.o gtkUserFuncs.o pangoAccessors.o pangoClasses.o pangoConversion.o pangoFuncs.o pangoManuals.o pangoUserFuncs.o utils.o zcompat.o -L/usr/lib/mxe/usr/x86_64-w64-mingw32.static.posix/lib -lgdk-win32-2.0 -lgtk-win32-2.0 -limm32 -lshell32 -L/usr/lib/mxe/usr/x86_64-w64-mingw32.static.posix/lib/../lib -lws2_32 -lws2_32 -lpangocairo-1.0 -lws2_32 -lws2_32 -lws2_32 -lws2_32 -lws2_32 -latk-1.0 -lws2_32 -lexpat -lwebp -lzstd -llzma -ljpeg -luuid -lz -lwinspool -lcomctl32 -lcomdlg32 -lpangoft2-1.0 -ltiff -lwebp -lzstd -llzma -lgdk_pixbuf-2.0 -ljpeg -lpangowin32-1.0 -lgmodule-2.0 -ldl -lffi -lpango-1.0 -lfribidi -L/usr/lib/mxe/usr/x86_64-w64-mingw32.static.posix/lib -lexpat -lcairo -lz -lmsimg32 -lgdi32 -lpixman-1 -lz -lz -lmsimg32 -lgdi32 -lpixman-1 -lgio-2.0 -ldl -ldnsapi -liphlpapi -lz -lole32 -lshlwapi -luuid -L/usr/lib/mxe/usr/x86_64-w64-mingw32.static.posix/lib -lpixman-1 -lfontconfig -L/usr/lib/mxe/usr/x86_64-w64-mingw32.static.posix/lib -lexpat -lharfbuzz -lfreetype -lbz2 -lpng16 -lz -lharfbuzz_too -lfreetype_too -lole32 -lshlwapi -lpcre -lgobject-2.0 -lglib-2.0 -luuid -lintl -liconv -pthread -lws2_32 -lwinmm -lm -lole32 -lshlwapi -luuid -LC:/rtools42/x86_64-w64-mingw32.static.posix/lib/x64 -LC:/rtools42/x86_64-w64-mingw32.static.posix/lib -LC:/PROGRA~1/R/R-42~1.2/bin/x64 -lR
C:\rtools42\x86_64-w64-mingw32.static.posix\bin/ld.exe: C:/rtools42/usr/lib/mxe/usr/x86_64-w64-mingw32.static.posix/lib/libatk-1.0.a(atktext.c.obj):atktext.c:(.text+0x2e60): multiple definition of `atk_text_free_ranges'; atkManuals.o:atkManuals.c:(.text+0x120): first defined here
C:\rtools42\x86_64-w64-mingw32.static.posix\bin/ld.exe: C:/rtools42/usr/lib/mxe/usr/x86_64-w64-mingw32.static.posix/lib/libgobject-2.0.a(gsourceclosure.c.obj):gsourceclosure:(.text+0x500): multiple definition of `g_io_condition_get_type'; gobject.o:gobject.c:(.text+0x5580): first defined here
C:\rtools42\x86_64-w64-mingw32.static.posix\bin/ld.exe: C:/rtools42/usr/lib/mxe/usr/x86_64-w64-mingw32.static.posix/lib/libgtk-win32-2.0.a(gtkmain.o): in function `gtk_set_locale':
/root/mxe/tmp-gtk2-x86_64-w64-mingw32.static.posix/gtk+-2.24.29.build_/gtk/../../gtk+-2.24.29/gtk/gtkmain.c:1155: undefined reference to `gdk_set_locale'
C:\rtools42\x86_64-w64-mingw32.static.posix\bin/ld.exe: C:/rtools42/usr/lib/mxe/usr/x86_64-w64-mingw32.static.posix/lib/libgtk-win32-2.0.a(gtktext.o): in function `gtk_text_get_chars':
/root/mxe/tmp-gtk2-x86_64-w64-mingw32.static.posix/gtk+-2.24.29.build_/gtk/../../gtk+-2.24.29/gtk/gtktext.c:1153: undefined reference to `gdk_wcstombs'
C:\rtools42\x86_64-w64-mingw32.static.posix\bin/ld.exe: C:/rtools42/usr/lib/mxe/usr/x86_64-w64-mingw32.static.posix/lib/libgtk-win32-2.0.a(gtktext.o): in function `gtk_text_insert':
/root/mxe/tmp-gtk2-x86_64-w64-mingw32.static.posix/gtk+-2.24.29.build_/gtk/../../gtk+-2.24.29/gtk/gtktext.c:965: undefined reference to `gdk_mbstowcs'
...
linking-error.txt
I'm trying to get RGtk to build on Windows, so that I can be confident that my package Retistruct will be usable in the future for Windows users (see this issue davidcsterratt/retistruct#52).
I was wondering if it would be possible to get RGtk to build using only the libraries available in Rtools, which appear to include all the required dependencies. It would then be possible (I suppose) to get new versions compiled using the win_builder service, which might assist with getting RGtk back on CRAN.
I've been experimenting with setting up the PKG_CPPLFAGS and PKG_LIBS in Makevars.win using the output from the pkg-config that I installed into the Rtools mingw32 system using pacman:
The source files compile to
.ofiles OK, but then there are linking issues - see truncated output below and the full output (attached). I fear I may be on a fool's errand, but any advice on what do to next would be much appreciated... I am reasonably experienced in building packages on Linux, but not on Windows.linking-error.txt