printdialog: fix sporadic win32 build failures
Private function gtk_print_setup_get_printer()
unconditionally calls
gtk_printer_find()
, which does not exist on Win32.
But gtk_print_setup_get_printer()
is never called either, so usually
that whole code gets optimized out.
Some compilation environment however do not cleanup unused functions,
leading to linker error as gtk_printer_find()
is not found.
This patch should solve the link issue.
Additional info
When compiling on win32, I always see these warnings:
../subprojects/gtk/gtk/gtkprintdialog.c:1678:11: warning: unused variable 'error' [-Wunused-variable]
1678 | GError *error = NULL;
| ^~~~~
../subprojects/gtk/gtk/gtkprintdialog.c: At top level:
../subprojects/gtk/gtk/gtkprintdialog.c:206:1: warning: 'gtk_print_setup_set_printer' defined but not used [-Wunused-function]
206 | gtk_print_setup_set_printer (GtkPrintSetup *setup,
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~
../subprojects/gtk/gtk/gtkprintdialog.c:189:1: warning: 'gtk_print_setup_get_printer' defined but not used [-Wunused-function]
189 | gtk_print_setup_get_printer (GtkPrintSetup *setup)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~
../subprojects/gtk/gtk/gtkprintdialog.c:182:1: warning: 'gtk_print_setup_set_page_setup' defined but not used [-Wunused-function]
182 | gtk_print_setup_set_page_setup (GtkPrintSetup *setup,
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../subprojects/gtk/gtk/gtkprintdialog.c:156:1: warning: 'gtk_print_setup_set_print_settings' defined but not used [-Wunused-function]
156 | gtk_print_setup_set_print_settings (GtkPrintSetup *setup,
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../subprojects/gtk/gtk/gtkprintdialog.c:82:1: warning: 'gtk_print_setup_new' defined but not used [-Wunused-function]
82 | gtk_print_setup_new (void)
| ^~~~~~~~~~~~~~~~~~~
But sometimes, depending on if gtk_print_setup_get_printer()
gets optimized out or not, the link fails:
[864/2563] Linking target subprojects/gtk/gtk/libgtk-4-1.dll
FAILED: subprojects/gtk/gtk/libgtk-4-1.dll
"cc" -o subprojects/gtk/gtk/libgtk-4-1.dll "-Wl,--allow-shlib-undefined" "-shared" "-Wl,--start-group" "-Wl,--out-implib=subprojects/gtk/gtk/libgtk-4.dll.a" "-Wl,--whole-archive" "subprojects/gtk/gtk/libgtk.a" "subprojects/gtk/gtk/css/libgtk_css.a" "subprojects/gtk/gdk/libgdk.a" "subprojects/gtk/gsk/libgsk.a" "-Wl,--no-whole-archive" "subprojects/gtk/gsk/libgsk_f16c.a" "-Wl,-Bsymbolic" "C:/msys64/ucrt64/lib/libgmodule-2.0.dll.a" "C:/msys64/ucrt64/lib/libglib-2.0.dll.a" "C:/msys64/ucrt64/lib/libintl.dll.a" "C:/msys64/ucrt64/lib/libgobject-2.0.dll.a" "C:/msys64/ucrt64/lib/libgio-2.0.dll.a" "C:/msys64/ucrt64/lib/libpangocairo-1.0.dll.a" "C:/msys64/ucrt64/lib/libpango-1.0.dll.a" "C:/msys64/ucrt64/lib/libharfbuzz.dll.a" "C:/msys64/ucrt64/lib/libcairo.dll.a" "C:/msys64/ucrt64/lib/libharfbuzz-subset.dll.a" "C:/msys64/ucrt64/lib/libfribidi.dll.a" "C:/msys64/ucrt64/lib/libcairo-gobject.dll.a" "C:/msys64/ucrt64/lib/libgdk_pixbuf-2.0.dll.a" "C:/msys64/ucrt64/lib/libepoxy.dll.a" "-lm" "C:/msys64/ucrt64/lib/libgraphene-1.0.dll.a" "C:/msys64/ucrt64/lib/libpangowin32-1.0.dll.a" "-ladvapi32" "-lcomctl32" "-lcrypt32" "-ldwmapi" "-limm32" "-lsetupapi" "-lwinmm" "C:/msys64/ucrt64/lib/libpangoft2-1.0.dll.a" "C:/msys64/ucrt64/lib/libfontconfig.dll.a" "C:/msys64/ucrt64/lib/libfreetype.dll.a" "-lintl" "C:/msys64/ucrt64/lib/libpng16.dll.a" "C:/msys64/ucrt64/lib/libtiff.dll.a" "C:/msys64/ucrt64/lib/libjpeg.dll.a" "-lhid" "-lopengl32" "C:/msys64/ucrt64/lib/libcairo-script-interpreter.dll.a" "-ladvapi32" "-lcomctl32" "-lcrypt32" "-ldwmapi" "-limm32" "-lsetupapi" "-lwinmm" "-lintl" "-lhid" "-lopengl32" "-lhid" "-lopengl32" "-lhid" "-lopengl32" "-lhid" "-lopengl32" "-lkernel32" "-luser32" "-lgdi32" "-lwinspool" "-lshell32" "-lole32" "-loleaut32" "-luuid" "-lcomdlg32" "-Wl,--end-group"
C:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/14.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: subprojects/gtk/gtk/libgtk.a.p/gtkprintdialog.c.obj: in function `gtk_print_setup_get_printer':
C:\_r\_builds\vJWzEqDv\0\g.willems\gnome-text-editor\builddir/../subprojects/gtk/gtk/gtkprintdialog.c:199:(.text+0x400): undefined reference to `gtk_printer_find'
collect2.exe: error: ld returned 1 exit status
A full build failure log, for reference:
.