-
Notifications
You must be signed in to change notification settings - Fork 71
Building a GtkD GTK3 Application on OSX
This is not intended to be a comprehensive guide, just a list of tips that should save debugging time.
Follow the instructions on the Gnome Wiki.
Be sure to run jhbuild build meta-gtk-osx-gtk3
as documented towards the bottom of the page.
Simply running make -f GNUMakefile gtkd
from the GtkD directory should be enough.
Here is a makefile snippet that should help create the correct linker flags on OSX and Linux:
UNAME := $(shell uname)
ifeq ("$(UNAME)", "Darwin")
GTK_LIBS := -L-L$(HOME)/gtk/inst/lib -L-rpath -L$(HOME)/gtk/inst/lib\
-L-lgtk-3 -L-lgdk-3 -L-latk-1.0 -L-lgio-2.0 -L-lpangocairo-1.0\
-L-lgdk_pixbuf-2.0 -L-lcairo-gobject -L-lpango-1.0 -L-lcairo -L-lgobject-2.0\
-L-lglib-2.0
else
GTK_LIBS := $(shell pkg-config gtk+-3.0 --libs | sed -e "s/-l/-L-l/g")
endif
Follow the directions on the Gnome Wiki for bundling, but with the following changes:
Add the following items to your .bundle file:
<binary>
${prefix}/lib/pango/${pkg:pango:pango_module_version}/modules
</binary>
<data>
${prefix}/etc
</data>
<data>
${prefix}/share/glib-2.0/schemas
</data>
<icon-theme icons="all">
hicolor
</icon-theme>
- pango stuff: This causes the pango modules to be included in the generated bundle. Leaving this out will give you an application bundle that is unable to draw text.
-
/etc
: This needs to be included so that various files necessary for GTK3 widgets will be included in the bundle. -
/share/glib-2.0/schemas
: This line causes other files necessary for the GTK file chooser widget (and possibly others) to be included in your .app. See this Stack Overflow question for details. -
icon-theme
: Useall
to include enough icons for GTK to work correctly.
The sample launcher script contains a line that sets the PANGO_RC_FILE environment variable, but it seems that this doesn't actually do anything. Your program will still continue to look for Pango configuration in the inst
directory in your gtk/jhbuild directory. To fix this, add the following lines to your launcher script:
export PANGO_LIBDIR="$bundle_lib"
export PANGO_SYSCONFDIR="$bundle_etc"
The binary produced by the above makefile snippet has a problem: It will look for its dynamic libraries using names such as "libcairo.dylib", but the mac bundler script will pull in "libcairo.2.dylib". There are several .dylib files that are affected by this. You can fix the runtime linking errors by adding the following step to your build process:
# "the_program" is the name of the program being bundled
# Remove the old version
rm -r the_program.app
# Bundle the new version
gtk-mac-bundler the_program.bundle
# Move into the .app folder and fix the library symlinks.
pushd the_program.app/Contents/Resources/lib \
&& ln -s libcairo.2.dylib libcairo.dylib \
&& ln -s libglib-2.0.0.dylib libglib-2.0.dylib \
&& ln -s libgmodule-2.0.0.dylib libgmodule-2.0.dylib \
&& ln -s libgobject-2.0.0.dylib libgobject-2.0.dylib \
&& ln -s libgdk_pixbuf-2.0.0.dylib libgdk_pixbuf-2.0.dylib \
&& ln -s libgio-2.0.0.dylib libgio-2.0.dylib \
&& ln -s libatk-1.0.0.dylib libatk-1.0.dylib \
&& ln -s libpango-1.0.0.dylib libpango-1.0.dylib \
&& ln -s libpangocairo-1.0.0.dylib libpangocairo-1.0.dylib \
&& popd