i 've a problem trying to compile a simple C Extension, that actually do
nothing, only print an hello message.
If from XCode i create and build a new Ruby C Extension, then i try to
recall it from a ruby script, that use the ruby interpreter compiled
from MacPort , a BUS ERROR is returned, au contraire, if i use the
Leopard's ruby interpreter, it works.
Already tried to change the XCode project target properties to 32 and
64bit but no way to work with that ,and i do non understand why, 2 ruby
interpreters can't use the same c extension.
i 've a problem trying to compile a simple C Extension, that actually do
nothing, only print an hello message.
If from XCode i create and build a new Ruby C Extension, then i try to
recall it from a ruby script, that use the ruby interpreter compiled
from MacPort , a BUS ERROR is returned, au contraire, if i use the
Leopard's ruby interpreter, it works.
Already tried to change the XCode project target properties to 32 and
64bit but no way to work with that ,and i do non understand why, 2 ruby
interpreters can't use the same c extension.
2 different ruby interpreters, built in entirely different ways, are not necessarily compatible with each other. You need to build each and every extension for a specific interpreter. Take a look at how inline works:
#!/usr/bin/ruby -w
require 'rubygems'
require 'inline'
class Demo
inline(:C) do |builder|
builder.c 'void hello() { puts("hello"); }'
end
end
Since the built-in Leopard build of Ruby is the future for OS X, I would recommend focusing your efforts there. (and maybe 1.9...)
Clearly, at this time, Apple is taking Ruby pretty seriously. MacPorts can introduce additional complexities to the situation. If you still want to get it working, by all means, do it. I'm just saying that the future of a stable, predictable OS X Ruby distribution is likely to be the one that is bundled.
On the other hand, if you have older Macs you need to support that does not fix things, does it?
Let's just hope the MS and Mac versions of Ruby don't diverge too much... (beyond their native Frameworks of course)
···
On Mar 22, 2008, at 8:10 AM, Wladjmir Wlj wrote:
Hi,
i 've a problem trying to compile a simple C Extension, that actually do
nothing, only print an hello message.
If from XCode i create and build a new Ruby C Extension, then i try to
recall it from a ruby script, that use the ruby interpreter compiled
from MacPort , a BUS ERROR is returned, au contraire, if i use the
Leopard's ruby interpreter, it works.
Already tried to change the XCode project target properties to 32 and
64bit but no way to work with that ,and i do non understand why, 2 ruby
interpreters can't use the same c extension.
I'd recommend using mkmf to build your extension as part of the
installation process, rather than trying to build it yourself. That
way your extension should work on any Ruby installation. I don't know
what formal documentation there is for it; personally I just copied
the extconf.rb script from another project (which copied it from
another project...), so feel free to repeat the pattern if it helps.
Obviously if you want to distribute a binary version of your extension
for the convenience of your users (since not all OS X users have gcc
installed by default), you'll need to create a separate distribution
for each Ruby build you want to support. But hey, you can deal with
that problem when you get to it.
HTH
has
···
On 22 Mar, 13:10, Wladjmir Wlj <wladj...@galsport.com> wrote:
Hi,
i 've a problem trying to compile a simple C Extension, that actually do
nothing, only print an hello message.
If from XCode i create and build a new Ruby C Extension, then i try to
recall it from a ruby script, that use the ruby interpreter compiled
from MacPort , a BUS ERROR is returned, au contraire, if i use the
The Xcode template will produce an extension that may only work for
the version of Ruby that ships with the system. I don't know why it
doesn't work with the version in MacPorts, could you provide more
feedback about this (like a backtrace)? Maybe it's because the
extension is built 2-way fat (for i386 and ppc) by default.
Anyway if you want to write an extension that should be portable with
different versions of Ruby, as others suggested you should use mkmf.
Laurent
···
On Sat, Mar 22, 2008 at 6:10 AM, Wladjmir Wlj <wladjmir@galsport.com> wrote:
Hi,
i 've a problem trying to compile a simple C Extension, that actually do
nothing, only print an hello message.
If from XCode i create and build a new Ruby C Extension, then i try to
recall it from a ruby script, that use the ruby interpreter compiled
from MacPort , a BUS ERROR is returned, au contraire, if i use the
Leopard's ruby interpreter, it works.
Already tried to change the XCode project target properties to 32 and
64bit but no way to work with that ,and i do non understand why, 2 ruby
interpreters can't use the same c extension.
The Xcode template will produce an extension that may only work for
the version of Ruby that ships with the system. I don't know why it
doesn't work with the version in MacPorts, could you provide more
feedback about this (like a backtrace)? Maybe it's because the
extension is built 2-way fat (for i386 and ppc) by default.
Anyway if you want to write an extension that should be portable with
different versions of Ruby, as others suggested you should use mkmf.
Laurent
Thanks all,
i unistalled macport version of ruby... the simple way.
Just curious,it disturb me that my extension could not work on another
machine, and i do not understand why, afterall the ruby source files are
the same.
if i build manually with extconf -> make it work with both, then the
problem is some configuration on XCode? i would like to use RubyCocoa
for some project so i want to learn something more about how it works
with ruby.
i already tried to build only i38, the only error i get is BUS ERROR -
Abort trap follow the crash report :