[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Re: Cross Compiling Ruby Extension

Mauricio Fernández

10/18/2006 6:54:00 PM

On Wed, Oct 18, 2006 at 04:58:53PM +0900, Brian Takita wrote:
> Hello,
>
> I'm attempting to cross compile a ruby extension for Windows from a Linux
> box.
> Im running Ubuntu 6.06, Ruby 1.8.5, and mingw gcc 3.4.4.
>
> I attempted to follow Mauricio Fernandez's instructions
> http://eige.../hiki.rb?cross+compiling+...
>
> The file compiled but it appears that it is still a Linux binary.
> json_ext.so: ELF 32-bit LSB shared object, Intel 80386, version 1 (SYSV),
> not stripped

You are using mkrf instead of mkmf, so things work a bit differently.

$ cat extconf.rb
require 'rubygems'
require 'mkrf'

dir = File.dirname(__FILE__)
Mkrf::Generator.new('json_ext', "#{dir}/*.c")
$ cat > extconf.rb
require 'mkmf'
create_makefile "json_ext"
$ ruby -I ~/usr/ruby-mingw32/lib/ruby/1.8/i386-mingw32 extconf.rb
/home/batsman/ruby-mingw32/lib/ruby/1.8/i386-mingw32/rbconfig.rb:7: ruby lib version (1.8.4) doesn't match executable version (1.8.5) (RuntimeError)
from /home/batsman/usr//lib/ruby/1.8/mkmf.rb:4:in `require'
from /home/batsman/usr//lib/ruby/1.8/mkmf.rb:4
from extconf.rb:1:in `require'
from extconf.rb:1

[use vim to edit rbconfig.rb and remove/comment the version check if the
native & cross-compiled ruby version differ]

$ ruby -I ~/ruby-mingw32/lib/ruby/1.8/i386-mingw32/ extconf.rb
creating Makefile
$ make
i586-mingw32msvc-gcc -I. -I/home/batsman/ruby-mingw32/lib/ruby/1.8/i386-mingw32 -I/home/batsman/ruby-mingw32/lib/ruby/1.8/i386-mingw32 -I. -g -O2 -c json_ext.c
i586-mingw32msvc-gcc -shared -s -Wl,--enable-auto-import,--export-all -L"/home/batsman/ruby-mingw32/lib" -o json_ext.so json_ext.o -lmsvcrt-ruby18 -lwsock32
$ file json_ext.so
json_ext.so: MS Windows PE 32-bit Intel 80386 console DLL

--
Mauricio Fernandez - http://eige... - singular Ruby

5 Answers

Brian Takita

10/19/2006 2:02:00 AM

0



On 10/18/06, Mauricio Fernandez <mfp@acm.org> wrote:
>
> On Wed, Oct 18, 2006 at 04:58:53PM +0900, Brian Takita wrote:
> > Hello,
> >
> > I'm attempting to cross compile a ruby extension for Windows from a
> Linux
> > box.
> > Im running Ubuntu 6.06, Ruby 1.8.5, and mingw gcc 3.4.4.
> >
> > I attempted to follow Mauricio Fernandez's instructions
> > http://eige.../hiki.rb?cross+compiling+...
> >
> > The file compiled but it appears that it is still a Linux binary.
> > json_ext.so: ELF 32-bit LSB shared object, Intel 80386, version 1
> (SYSV),
> > not stripped
>
> You are using mkrf instead of mkmf, so things work a bit differently.
>
> $ cat extconf.rb
> require 'rubygems'
> require 'mkrf'
>
> dir = File.dirname(__FILE__)
> Mkrf::Generator.new('json_ext', "#{dir}/*.c")
> $ cat > extconf.rb
> require 'mkmf'
> create_makefile "json_ext"
> $ ruby -I ~/usr/ruby-mingw32/lib/ruby/1.8/i386-mingw32 extconf.rb
> /home/batsman/ruby-mingw32/lib/ruby/1.8/i386-mingw32/rbconfig.rb:7: ruby
> lib version (1.8.4) doesn't match executable version (1.8.5)
> (RuntimeError)
> from /home/batsman/usr//lib/ruby/1.8/mkmf.rb:4:in `require'
> from /home/batsman/usr//lib/ruby/1.8/mkmf.rb:4
> from extconf.rb:1:in `require'
> from extconf.rb:1
>
> [use vim to edit rbconfig.rb and remove/comment the version check if the
> native & cross-compiled ruby version differ]
>
> $ ruby -I ~/ruby-mingw32/lib/ruby/1.8/i386-mingw32/ extconf.rb
> creating Makefile
> $ make
> i586-mingw32msvc-gcc -I.
> -I/home/batsman/ruby-mingw32/lib/ruby/1.8/i386-mingw32
> -I/home/batsman/ruby-mingw32/lib/ruby/1.8/i386-mingw32 -I. -g -O2 -c
> json_ext.c
> i586-mingw32msvc-gcc -shared -s
> -Wl,--enable-auto-import,--export-all -L"/home/batsman/ruby-mingw32/lib" -o
> json_ext.so json_ext.o -lmsvcrt-ruby18 -lwsock32
> $ file json_ext.so
> json_ext.so: MS Windows PE 32-bit Intel 80386 console DLL


Thanks for demoing this. I'll give it a shot.

--
> Mauricio Fernandez - http://eige... - singular Ruby
>
>



On 10/18/06, <b class="gmail_sendername">Mauricio Fernandez</b> &lt;<a href="mailto:mfp@acm.org">mfp@acm.org</a>&gt; wrote:<div><span class="gmail_quote"></span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
On Wed, Oct 18, 2006 at 04:58:53PM +0900, Brian Takita wrote:<br>&gt; Hello,<br>&gt;<br>&gt; I'm attempting to cross compile a ruby extension for Windows from a Linux<br>&gt; box.<br>&gt; Im running Ubuntu 6.06, Ruby 1.8.5
, and mingw gcc 3.4.4.<br>&gt;<br>&gt; I attempted to follow Mauricio Fernandez's instructions<br>&gt; <a href="http://eige.../hiki.rb?cross+compiling+...">http://eige.../hiki.rb?cross+compiling+...
</a><br>&gt;<br>&gt; The file compiled but it appears that it is still a Linux binary.<br>&gt; json_ext.so: ELF 32-bit LSB shared object, Intel 80386, version 1 (SYSV),<br>&gt; not stripped<br><br>You are using mkrf instead of mkmf, so things work a bit differently.
<br><br>$ cat extconf.rb<br>require 'rubygems'<br>require 'mkrf'<br><br>dir = File.dirname(__FILE__)<br>Mkrf::Generator.new('json_ext', &quot;#{dir}/*.c&quot;)<br>$ cat &gt; extconf.rb<br>require 'mkmf'<br>create_makefile &quot;json_ext&quot;
<br>$ ruby -I ~/usr/ruby-mingw32/lib/ruby/1.8/i386-mingw32 extconf.rb<br>/home/batsman/ruby-mingw32/lib/ruby/1.8/i386-mingw32/rbconfig.rb:7: ruby lib version (1.8.4) doesn't match executable version (1.8.5) (RuntimeError)
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;from /home/batsman/usr//lib/ruby/1.8/mkmf.rb:4:in `require'<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;from /home/batsman/usr//lib/ruby/1.8/mkmf.rb:4<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;from extconf.rb:1:in `require'<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;from extconf.rb:1<br><br>[use vim to edit
rbconfig.rb and remove/comment the version check if the<br>native &amp; cross-compiled ruby version differ]<br><br>$ ruby -I ~/ruby-mingw32/lib/ruby/1.8/i386-mingw32/ extconf.rb<br>creating Makefile<br>$ make<br>i586-mingw32msvc-gcc -I. -I/home/batsman/ruby-mingw32/lib/ruby/1.8/i386-mingw32 -I/home/batsman/ruby-mingw32/lib/ruby/1.8/i386-mingw32 -I.&nbsp;&nbsp;-g -O2&nbsp;&nbsp; -c json_ext.c
<br>i586-mingw32msvc-gcc -shared -s -Wl,--enable-auto-import,--export-all&nbsp;&nbsp;-L&quot;/home/batsman/ruby-mingw32/lib&quot; -o json_ext.so json_ext.o&nbsp;&nbsp;-lmsvcrt-ruby18&nbsp;&nbsp;-lwsock32<br>$ file json_ext.so<br>json_ext.so: MS Windows PE 32-bit Intel 80386 console DLL
</blockquote><div><br>Thanks for demoing this. I'll give it a shot. <br></div><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">--<br>Mauricio Fernandez&nbsp;&nbsp;-&nbsp;&nbsp;
<a href="http://eige...">http://eige...</a>&nbsp;&nbsp; -&nbsp;&nbsp;singular Ruby<br><br></blockquote></div><br>


rfischer

9/14/2010 3:23:00 PM

0

NoBody <nobody@nowhere.com> wrote:
> rfischer@sonic.net (Ray Fischer) wrote:
>>Ray Fischer <rfischer@sonic.net> wrote:
>>>NoBody <nobody@nowhere.com> wrote:
>>>> rfischer@sonic.net (Ray Fischer) wrote:
>>>>>NoBody <nobody@nowhere.com> wrote:
>>>>>> rfischer@sonic.net (Ray Fischer) wrote:
>>>>>>>Daniel <sabot120mm@hotmail.com> wrote:
>>
>>>>>>>>IF you were to ever refute a claim,
>>>>>>>
>>>>>>>Already done. GM is not being run by the government and so you are
>>>>>>>branded once again as an idiot liar.
>>>>>>
>>>>>>Are they are are they not the majority share holder in GM?
>>>>>
>>>>>Are you too stupid to understand what it means to RUN a company?
>>>>
>>>>Are you?
>>>
>>>Who is the government employee that is actively running GM?
>>
>>Nothing but crickets.
>
>Idiot ray-ray still doesn't understand the definition of the term even

The asshole lied and is now trying to redefine words.

--
Ray Fischer
rfischer@sonic.net

John Doe

9/14/2010 9:53:00 PM

0

On 14 Sep 2010 15:22:52 GMT, rfischer@sonic.net (Ray Fischer) wrote:

>NoBody <nobody@nowhere.com> wrote:
>> rfischer@sonic.net (Ray Fischer) wrote:
>>>Ray Fischer <rfischer@sonic.net> wrote:
>>>>NoBody <nobody@nowhere.com> wrote:
>>>>> rfischer@sonic.net (Ray Fischer) wrote:
>>>>>>NoBody <nobody@nowhere.com> wrote:
>>>>>>> rfischer@sonic.net (Ray Fischer) wrote:
>>>>>>>>Daniel <sabot120mm@hotmail.com> wrote:
>>>
>>>>>>>>>IF you were to ever refute a claim,
>>>>>>>>
>>>>>>>>Already done. GM is not being run by the government and so you are
>>>>>>>>branded once again as an idiot liar.
>>>>>>>
>>>>>>>Are they are are they not the majority share holder in GM?
>>>>>>
>>>>>>Are you too stupid to understand what it means to RUN a company?
>>>>>
>>>>>Are you?
>>>>
>>>>Who is the government employee that is actively running GM?
>>>
>>>Nothing but crickets.
>>
>>Idiot ray-ray still doesn't understand the definition of the term even
>
>The asshole lied and is now trying to redefine words.

What lie ray-ray? I said the government is the majority shareholder
of GM and as such effectively controls the company. You can quibble
about if there's a difference between "controlling" the company and
"running" the company, but the government has control of GM.

John Doe

9/14/2010 9:54:00 PM

0

On 14 Sep 2010 15:22:04 GMT, rfischer@sonic.net (Ray Fischer) wrote:

>NoBody <nobody@nowhere.com> wrote:
>> rfischer@sonic.net (Ray Fischer) wrote:
>>>Ray Fischer <rfischer@sonic.net> wrote:
>>>>Ray Fischer <rfischer@sonic.net> wrote:
>>>>>NoBody <nobody@nowhere.com> wrote:
>>>>>> rfischer@sonic.net (Ray Fischer) wrote:
>>>>>>>NoBody <nobody@nowhere.com> wrote:
>>>>>>>> rfischer@sonic.net (Ray Fischer) wrote:
>>>>>>>>>Daniel <sabot120mm@hotmail.com> wrote:
>>>>
>>>>>>>>>>IF you were to ever refute a claim,
>>>>>>>>>
>>>>>>>>>Already done. GM is not being run by the government and so you are
>>>>>>>>>branded once again as an idiot liar.
>>>>>>>>
>>>>>>>>Are they are are they not the majority share holder in GM?
>>>>>>>
>>>>>>>Are you too stupid to understand what it means to RUN a company?
>>>>>>
>>>>>>Are you?
>>>>>
>>>>>Who is the government employee that is actively running GM?
>>>>
>>>>Nothing but crickets.
>>>
>>>chirp chirp.
>>
>>Idiot ray-ray still doesn't understand the definition of the term even
>
>The stupid asshole still can't answer the question. But since its
>claim is a complete lie then of course it cannot provide any evidence.

I never said there was a government employee running GM. It's a shame
you have such honesty problems.

rfischer

9/15/2010 3:33:00 AM

0

NoBody <nobody@nowhere.com> wrote:
> rfischer@sonic.net (Ray Fischer) wrote:
>>Ray Fischer <rfischer@sonic.net> wrote:
>>>Ray Fischer <rfischer@sonic.net> wrote:
>>>>NoBody <nobody@nowhere.com> wrote:
>>>>> rfischer@sonic.net (Ray Fischer) wrote:
>>>>>>NoBody <nobody@nowhere.com> wrote:
>>>>>>> rfischer@sonic.net (Ray Fischer) wrote:
>>>>>>>>Daniel <sabot120mm@hotmail.com> wrote:
>>>
>>>>>>>>>IF you were to ever refute a claim,
>>>>>>>>
>>>>>>>>Already done. GM is not being run by the government and so you are
>>>>>>>>branded once again as an idiot liar.
>>>>>>>
>>>>>>>Are they are are they not the majority share holder in GM?
>>>>>>
>>>>>>Are you too stupid to understand what it means to RUN a company?
>>>>>
>>>>>Are you?
>>>>
>>>>Who is the government employee that is actively running GM?
>>>
>>>Nothing but crickets.
>>
>>chirp chirp.
>
>Idiot ray-ray still doesn't understand the definition of the term

"Irony anybody?"

--
Ray Fischer
rfischer@sonic.net