Yes, I realise this is a bit evil, so maybe it's just lucky that it
didn't cause problems on the linux side. However, I get the same crash
when I call a test function (with the correct signature) that is
simply *linking* the gtk library:

#include <gtk/gtk.h>

int times2(int i) {
  return i*2;
}

This, built with:

gcc -fPIC -c ml_helpers.c -o ml_helpers.o `pkg-config --cflags gtk+-2.0`
gcc -shared -Wl -o ../libpolygtk.so ml_helpers.o `pkg-config --libs gtk+-2.0`


To answer your other question: I am in the process of writing some
very basic GTK bindings for Poly, at least initially for rapid
prototyping and testing. There's a github project:

https://github.com/akissinger/polygtk

I've had success getting the two included examples (some buttons w.
callbacks and text entry) working in linux, but this mysterious crash
is holding up OS X support.

a

On 25 June 2012 16:27, Phil Clayton <[email protected]> wrote:
> On 24/06/12 01:47, Aleks Kissinger wrote:
>>
>> Any idea why calling symbols from certain shared libraries would cause
>> poly/ML to crash on OS X? Example:
>>
>>> val gtk = load_lib "libgtk-quartz-2.0.dylib";
>>
>> val gtk = ?: dylib
>>>
>>> val gtk_init = call2 (load_sym gtk "gtk_init") (INT,INT) VOID;
>>
>> val gtk_init = fn: int * int ->  unit
>>>
>>> gtk_init(0,0);
>>
>> [1]    96630 killed     rlwrap -z  poly
>
>
> It doesn't completely surprise me that this crashes: gtk_init has the
> signature
>
>  void gtk_init (int *argc, char ***argv);
>
> so you're using the conversion INT for passing a pointer.  INT is same size
> as the C int, which is likely to be 32 bits on a 64 bit platform. However,
> on a 64 bit platform, a pointer should be 64 bits.  I suspect that this,
> possibly along with different calling conventions, might cause the variation
> you see between platforms.
>
> The conversion LONG will give you the C long, usually the same size as a
> pointer, but you really want to be using the conversions POINTER or
> POINTERTO for passing pointers.
>
> Out of interest, are you attempting to use GTK+ from SML?
>
> Phil
_______________________________________________
polyml mailing list
[email protected]
http://lists.inf.ed.ac.uk/mailman/listinfo/polyml

Reply via email to