Normally gtk2 will be installed on OS X by typing:
sudo port install gtk2
But at times errors can occur. These errors are supposed to be fixed by the gtk2 maintainer or the maintainer of the ports that gtk2 depends on.
Some errors and solutions are found below.
---> Building gtk2 with target all
Error: Target com.apple.build returned: shell command "cd "/opt/local/var/db/dports/build/_opt_local_var_db_dports_sources_rsync.rsync.darwinports.org_dpupdate_dports_x11_gtk2/work/gtk+-2.10.9" && make all CFLAGS+="-I/usr/X11R6/include"" returned error 2
Command output: gtkprintbackendcups.c:2322: error: request for member `num_groups' in something not a structure or union
gtkprintbackendcups.c:2323: error: request for member `groups' in something not a structure or union
gtkprintbackendcups.c: At top level:
gtkprintbackendcups.c:2333: error: parse error before "ppd_file_t"
gtkprintbackendcups.c:2333: warning: no semicolon at end of struct or union
gtkprintbackendcups.c: In function `foreach_option_get_settings':
gtkprintbackendcups.c:2576: error: dereferencing pointer to incomplete type
gtkprintbackendcups.c: In function `cups_printer_get_settings_from_options':
gtkprintbackendcups.c:2628: error: storage size of `data' isn't known
gtkprintbackendcups.c: In function `cups_printer_list_papers':
gtkprintbackendcups.c:2724: error: `ppd_file_t' undeclared (first use in this function)
gtkprintbackendcups.c:2725: error: `ppd_size_t' undeclared (first use in this function)
gtkprintbackendcups.c:2725: error: `size' undeclared (first use in this function)
gtkprintbackendcups.c:2729: error: `ppd_option_t' undeclared (first use in this function)
gtkprintbackendcups.c:2729: error: `option' undeclared (first use in this function)
gtkprintbackendcups.c:2730: error: `ppd_choice_t' undeclared (first use in this function)
gtkprintbackendcups.c:2730: error: `choice' undeclared (first use in this function)
gtkprintbackendcups.c:2740: error: request for member `num_sizes' in something not a structure or union
gtkprintbackendcups.c:2742: error: request for member `sizes' in something not a structure or union
gtkprintbackendcups.c: In function `cups_printer_get_hard_margins':
gtkprintbackendcups.c:2783: error: `ppd_file_t' undeclared (first use in this function)
gtkprintbackendcups.c:2789: error: request for member `custom_margins' in something not a structure or union
gtkprintbackendcups.c:2790: error: request for member `custom_margins' in something not a structure or union
gtkprintbackendcups.c:2791: error: request for member `custom_margins' in something not a structure or union
gtkprintbackendcups.c:2792: error: request for member `custom_margins' in something not a structure or union
make[4]: *** [gtkprintbackendcups.lo] Error 1
make[3]: *** [all-recursive] Error 1
make[2]: *** [all-recursive] Error 1
make[1]: *** [all-recursive] Error 1
make: *** [all] Error 2
Error: Status 1 encountered during processing.
The workaround is this: Install cups-headers, using sudo port install cups-headers. Then edit out the "exit 0" statement from the gtk2 Portfile so it will install with cups-headers. The Portfile is normally located in directory /opt/local/var/db/dports/sources/rsync.rsync.darwinports.org_dpupdate_dports/x11/gtk2. There is a bit in the Portfile that looks so:
if {[file exists ${prefix}/bin/cups-config]} {
ui_msg "\nThe cups-headers port may prevent building this port. Please uninstall\n(or deactivate) cups-headers and restart the build.\n"
exit 1
}
That whole bit should be taken out. Then run sudo port install gtk2 again, and it should work.
Sometimes the build fails because the portfiles were not updated. Always run:
sudo port selfupdate
If that has been done, then the build that failed should be cleaned out, and installed fresly, e.g. for libiconv:
sudo port clean libiconv
sudo port install libiconv
That should fix it.