Diane Trout (alienghic) wrote,
Diane Trout
alienghic

gtk-sharp on os x without x11

I've achieved some success getting mono and gtk to run on my OS X laptop. I ended up grabbing mono-1.1.18.20061018 off of the daily snapshots, and then discovered that I needed a small "hackish" patch from Allan Hsu on the mono-osx list in order to get it to build correctly.


Index: libgc/darwin_stop_world.c
===================================================================
--- libgc/darwin_stop_world.c (revision 65895)
+++ libgc/darwin_stop_world.c (working copy)
@@ -92,9 +92,11 @@
lo = GC_approx_sp();
} else {
/* Get the thread state (registers, etc) */
+ /* MACHINE_THREAD_STATE is broken in the new 10.4u SDK that comes with XCode 2.4 */
r = thread_get_state(
p->stop_info.mach_thread,
- MACHINE_THREAD_STATE,
+ 1,
+ /* MACHINE_THREAD_STATE, */
(natural_t*)&state,
&thread_state_count);
if(r != KERN_SUCCESS) ABORT("thread_get_state failed");
@@ -193,7 +195,7 @@
ppc_thread_state64_t info;
# endif
mach_msg_type_number_t outCount = THREAD_STATE_MAX;
- r = thread_get_state(thread, MACHINE_THREAD_STATE,
+ r = thread_get_state(thread, 1,
(natural_t *)&info, &outCount);
if(r != KERN_SUCCESS) continue;

@@ -236,7 +238,7 @@
WARN("This is completely untested and likely will not work\n", 0);
i386_thread_state_t info;
mach_msg_type_number_t outCount = THREAD_STATE_MAX;
- r = thread_get_state(thread, MACHINE_THREAD_STATE,
+ r = thread_get_state(thread, 1,
(natural_t *)&info, &outCount);
if(r != KERN_SUCCESS) continue;

Index: libgc/os_dep.c
===================================================================
--- libgc/os_dep.c (revision 65895)
+++ libgc/os_dep.c (working copy)
@@ -3702,7 +3702,7 @@
mask,
GC_ports.exception,
EXCEPTION_DEFAULT,
- MACHINE_THREAD_STATE
+ 1
);
if(r != KERN_SUCCESS) ABORT("task_set_exception_ports failed");


However I also wanted to use a native version of GTK instead of the one running through X11 (as X11 apps on OS X are kind of second class citizens. I managed to find the gtk+ for Mac OS X project which provided a rather nice build-gtk.sh script which handled grabbing all the dependencies and building GTK.

Finally I needed to link mono to gtk so I needed to build gtk-sharp, alas version 2.8.3 kept dying on me with some segfault in the gtk_init function. Thankfully when I pulled it out from the mono anonymous subversion archive:

svn://mono.myrealbox.com/source/trunk/gtk-sharp

today, it built.

I had a few problems getting mono to find the right libraries, the global assembly cache thought that gtk-sharp depended on gtk-x11.2.0.0.dylib, and I needed to edit lib/mono/gac/gtk-sharp/2.10.0.0__*/gtk-sharp.dll.config to include:

<dllmap dll="libgtk-x11.2.0-0.dll" target="libgtk-quartz-2.0.0.dylib"/>

Then I needed to update LD_LIBRARY_PATH to include /opt/gtk/lib (which was the default install path path used by the build-gtk.sh script.)

After doing all that the gtk-sharp samples ran mostly correctly.

I think I like that dllmap feature. It seems rather convienent to be able remap a dependency through a text file. Also the way that "assemblies" are named includes a cryptographic id as part of the name which makes it really easy to prevent name collisions between different versions of libraries with the same "human" name.

Next I want to get a slightly more mono friendly version of IronPython called FePy installed, and then see how to call C code from mono.
Tags: gtk, mono, os x
Subscribe

  • Guild Wars 2

    I started playing Guild Wars 2, and am happy their questing system has broken with WoW's current quest design. As WoW grew they "simplified" and…

  • calendar.

    Its been a really long time since I tried to write. I keep meaning to roll my own blog software, but there's so many other things I should be doing.…

  • Building debian packages for mozilla's sync server

    I'm surprised this seems to have gotten valid debian packages with a minimum of fuss for a package where I couldn't find a recommended release…

  • Post a new comment

    Error

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

  • 3 comments