C Extension on OSX crashes SU
-
I'm confused - are you using the SU Ruby Console or the IRB to test it?
> require 'mkmf'
Ohhh - now I see. That bit is what I used to compile the extension.TT_Hamster.bundle
is the compiled result of that.
You should only need to
require "TT_Hamster"
- this assumes that TT_Hamster.bundle is in the current working directory. -
I checked and have a similar problem. I have only been testing my extension in SketchUp on Windows and IRB on Windows/Mac. I'm going to look into it too and will post anything I find here.
Dan
-
@thomthom said:
I'm confused - are you using the SU Ruby Console or the IRB to test it?
> require 'mkmf'
Ohhh - now I see. That bit is what I used to compile the extension.TT_Hamster.bundle
is the compiled result of that.
You should only need to
require "TT_Hamster"
- this assumes that TT_Hamster.bundle is in the current working directory.You have to link as a flat namespace otherwise it won't work on OSX.
LDSHARED = cc -dynamic -bundle -undefined suppress -flat_namespace
-
I don't know at all what that line actually do, but I replaced what was generated by the extconf.rb file:
LDSHARED = cc -arch ppc -arch i386 -pipe -bundle -undefined dynamic_lookup
Using that line you posted and everything worked great!
I need to work out what it is this does. And how this make system works. I could not even recompile without erasing an .o file that was also generated last time I ran make.
Thank you very much Adam! I owe you a cookie!
-
I notice the old line had something in it,
-arch ppc
- would that have made it compatible with PPC macs?
I have an old G4 Mac Mini as well as the Intel Mac. Can I compile on the Intel mac in a manner so that the extension will run on both systems? -
You'll need to add:
"-arch i386 -arch ppc"
to CFLAGS and DLDFLAGS
This will make the Mac compiler build your code for both PowerPC and Intel CPUs.
-
Thanks!
How did you work out that flat namespace is needed for SU Ruby? Since it isn't needed for when you use the normal Ruby?
-
I guess it'd be worth compiling this info into a how-to article...
-
@thomthom said:
I guess it'd be worth compiling this info into a how-to article...
Did you do this? I can't found it...
-
@nikus_knx said:
@thomthom said:
I guess it'd be worth compiling this info into a how-to article...
Did you do this? I can't found it...
I got a Hello World project tutorial over at BitBucket:
https://bitbucket.org/thomthom/sketchup-ruby-c-extensionSCF thread related to the tutorial:
http://forums.sketchucation.com/viewtopic.php?f=180&t=41077
Advertisement