View previous topic :: View next topic |
Author |
Message |
armando.sano
Joined: 17 Jun 2011 Posts: 3
|
Posted: Fri Jun 17, 2011 11:41 am Post subject: Building GtkD 1.4.1 for MacOSX 10.6 with a prebuilt Gtk+ |
|
|
Hi there,
I thought I'd just share how I got to install GtkD on MacOSX 10.6.7 with dmd2 (v2.052) in a relatively quick and easy way. (If it's not the right place for that please redirect, thanks!)
First: the wiki page http://www.dsource.org/projects/gtkd/wiki/MacOSXNotes is outdated: the link to the quartz-native port of Gtk+ for mac os x is at http://gtk-osx.sourceforge.net/
Installing Gtk+
-----------------
Installing Gtk+-framework of gtk-osx didn't work for me for various reasons. However, I managed to install the equivalent (quartz-native) Gtk+ of gtk-osx but with unix-style library paths similar to MacPorts. This is a long route, though, this installation is not as straightforward as the notes at gtk-osx claim and I will not comment on this here, unless someone specifically asks for it.
I propose here a much easier (and to me preferred) route to install Gtk+ for MacOSX using a X11 (instead of Quartz) backend in packaged (prebuilt) form (maintained on "R for mac"'s developers' page). I would propose to add this route as a third option in http://www.dsource.org/projects/gtkd/wiki/MacOSXNotes:
1. Download and launch http://r.research.att.com/libs/GTK_2.18.5-X11.pkg
2. Add /Library/Framework/GTK+.framework/Resources/bin to your PATH
Advantages:
(a) doesn't rely on macports (which takes hours of downloading and installing dependencies), but on a quick and simple package install.
(b) The X11 backend seems much faster than using the Quartz backend, at least in one of my gtkd examples (about 100 times faster for a playing GUI simulation! but I guess it depends what is being done.)
Disadvantages:
(a) Gtk+-v2.18.5 is installed, a slightly older version compared to gtk-osx (which is currently 2.24).
(b) the X11 windowing system is launched in parallel with your GtkD application (and, obviously, required). The Quartz backend doesn't require this. Note, however, that the GTK look and feel is pretty much the same in both cases.
Installing GtkD (v1.4.1):
---------------------------
For some reason, although it seems highly recommended, I never was able to run DSSS properly on my machines. Certainly the lack of DSSS documentation doesn't help either. Unfortunately, this means going the dirty way: GNUmakefile, which is a bit outdated and erroenous, but luckily easily understandable and fixable.
1. Download and unzip gtkd-1.4.1.zip
2. Modify GNUmakefile as follows:
(a) Line 35-36: comment out the LDFLAGS line for "Darwin" (it is wrong and not needed) and add a DCFLAGS:
Code: | # LDFLAGS+=-Wl,-undefined,dynamic_lookup # original, outdated/wrong.
# LDFLAGS+=$(LINKERFLAG)-undefined $(LINKERFLAG)dynamic_lookup # fixed, but in fact not needed and best left out
DCFLAGS+=-version=darwinX11 # added |
(b) Line ~117: not all the wished libraries are shipped with GTK+2 as installed before (well, in fact, exactly the same libraries are shipped with the Quartz backend in my experience). Thus, libgtkdgl.a and libgtkdsv.a, libgda.a etc. cannot be compiled. Comment out 'gtkdgl sv' from the libs: line:
Code: | libs: gtkd # gtkdgl sv # comment out other libraries |
(c) Similar changes should be done under "install:", around lines 167-171, to ensure that those libraries are not attempted to be installed. (E.g. only keep the first two lines after the line saying "install: libs"). This is not strictly necessary, but if not done 'make install' below will exit with an error code, even though the gtkd library will install fine.
3. src/gtkc/path.d needs fixing + adapting for darwinX11 installation:
(a) Since not all expected GTK+ libraries are installed, modify Lines 23-48 as:
Code: | enum LIBRARY
{
ATK,
CAIRO,
GDK,
GDKPIXBUF,
GLIB,
GMODULE,
GOBJECT,
GIO,
GTHREAD,
GTK,
PANGO,
PANGOCAIRO,
// GLGDK, // missing
// GLGTK, // missing
GL,
GLU,
GLEXT,
// GDA, // missing
GLADE//, remove comma: last one
// GSV, // missing
// GSTREAMER, // missing
// GSTINTERFACES // missing
} |
(b) All the paths to the gtk+ libraries are specified in this paths.d file. If your libraries don't load properly at runtime, most probably a path is wrongly specified here. There are two major fixes to be done: const char [] needs to be replaced by const string [] everywhere (using phobos at least) and links to the libraries GIO and PANGOCAIRO need to be added. Lines ~96-123 will thus read:
Code: | version(darwinX11)
{
//This version is for the non-native OS X, X11 port
//of GTK+. This directory is according to the Macports http://www.macports.org
//default installation location. There should be installation instructions
//in the gtkD wiki at DSource.
const string DIRECTORY = "/Library/Frameworks/GTK+.framework/Versions/2.18.X11/Resources/lib/"; // modified
const string INTERFACE = "x11"; // modified
const string[LIBRARY.max+1] importLibs = // modified
[
LIBRARY.ATK: DIRECTORY~"libatk-1.0.dylib",
LIBRARY.CAIRO: DIRECTORY~"libcairo.dylib",
LIBRARY.GDK: DIRECTORY~"libgdk-"~INTERFACE~"-2.0.dylib",
LIBRARY.GDKPIXBUF: DIRECTORY~"libgdk_pixbuf-2.0.dylib",
LIBRARY.GLIB: DIRECTORY~"libglib-2.0.dylib",
LIBRARY.GMODULE: DIRECTORY~"libgmodule-2.0.dylib",
LIBRARY.GOBJECT: DIRECTORY~"libgobject-2.0.dylib",
LIBRARY.GIO: DIRECTORY~"libgio-2.0.dylib", // added: was missing!!!!
LIBRARY.GTHREAD: DIRECTORY~"libgthread-2.0.dylib",
LIBRARY.GTK: DIRECTORY~"libgtk-"~INTERFACE~"-2.0.dylib",
LIBRARY.PANGO: DIRECTORY~"libpango-1.0.dylib",
LIBRARY.PANGOCAIRO: DIRECTORY~"libpangocairo-1.0.dylib", // added: was missing!!!!
// LIBRARY.GLGDK: DIRECTORY~"libgdkglext-"~INTERFACE~"-1.0.dylib", // missing
// LIBRARY.GLGTK: DIRECTORY~"libgtkglext-"~INTERFACE~"-1.0.dylib", // missing
LIBRARY.GL: "/System/Library/Frameworks/OpenGL.framework/OpenGL",
LIBRARY.GLU: "/System/Library/Frameworks/OpenGL.framework/OpenGL",
LIBRARY.GLEXT: "/System/Library/Frameworks/OpenGL.framework/OpenGL",
// LIBRARY.GDA: DIRECTORY~"libgda-2.dylib", // missing
LIBRARY.GLADE: DIRECTORY~"libglade-2.0.dylib",
// LIBRARY.GSV: DIRECTORY~"libgtksourceview-1.0.dylib", // missing
// LIBRARY.GSTREAMER: DIRECTORY~"libgstreamer-0.10.dylib", // missing
// LIBRARY.GSTINTERFACES: DIRECTORY~"libgstinterfaces-0.10.dylib" // missing
];
} |
4. Everything should now be ready. To compile, run in a Terminal:
Code: | make -f GNUmakefile |
5. To test, you should already be able to run the TestWindow executable:
(there are several warnings/errors, but it should works). Alternatively, to compile and run the GtkD version of HelloWorld, do
Code: | dmd demos/gtk/HelloWorld.d -version=darwinX11 -Isrc -L-L. -L-lgtkd -ofHelloWorld
./HelloWorld |
(which has a lot less warnings, although some remain: about display 0x0....? Works fine anyway)
6. To install system-wide:
Code: | sudo make -f GNUmakefile install |
7. [Optional] Reconfigure the search path of dmd. Add the path /usr/local/include/d to your dmd.conf file (and /usr/local/lib if it's not already there), e.g. by having
Code: | -I%@P%/../include/d -L-L%@P%/../lib |
as part of the DFLAGS variable (the relative paths depend where dmd or dmd.conf is located on your system, I have mine under /usr/local/bin/)
8. To compile new gtkd projects (assuming 7. has been done): use the following flags for dmd:
Code: | -version=darwinX11 -L-lgtkd |
I hope this is useful
Armando |
|
Back to top |
|
|
Mike Wey
Joined: 07 May 2007 Posts: 428
|
Posted: Sat Jun 18, 2011 8:13 am Post subject: |
|
|
I've added the changes to the Makefile and paths.d (svn r854). Commenting out the missing libraries in paths.d shouldn't be needed, as long as you don't build the libraries that use them they aren't loaded. |
|
Back to top |
|
|
armando.sano
Joined: 17 Jun 2011 Posts: 3
|
Posted: Sat Jun 18, 2011 11:55 am Post subject: |
|
|
Mike Wey wrote: | I've added the changes to the Makefile and paths.d (svn r854). Commenting out the missing libraries in paths.d shouldn't be needed, as long as you don't build the libraries that use them they aren't loaded. |
Thanks for submitting the changes. You are right, commenting out the missing libraries was in fact not required (some attempts to load libraries will fail at run time in the worst case). Do you know if it is possible to compile these missing libraries from anywhere else for macosx?
Armando |
|
Back to top |
|
|
Mike Wey
Joined: 07 May 2007 Posts: 428
|
Posted: Sun Jun 19, 2011 4:57 am Post subject: |
|
|
armando.sano wrote: | Do you know if it is possible to compile these missing libraries from anywhere else for macosx?
Armando |
I don't know. |
|
Back to top |
|
|
armando.sano
Joined: 17 Jun 2011 Posts: 3
|
Posted: Sun Jun 19, 2011 8:57 am Post subject: |
|
|
Just a precision about my comment on the first post on speed for X11 vs Quartz backend: I was (mainly) in error. The speeds are roughly the same for most applications. In fact, I was experiencing very different speeds due to less numbers of effective expose events being issued by X11 compard to Quartz upon gtk.Widget.queueDraw() in a threaded loop (for reasons that still are beyond my understaning - but I am a newbie in threads and may have messed up something).
So although it is much more annoying to install the Quartz backend of GTK+ rather than the X11 backend, the Quartz backend actually works really well too.
Armando |
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|