On Windows how can I tell whether I'm running a 32-bit or 64-bit Ruby?

372 views
Skip to first unread message

Eric Promislow

unread,
Apr 12, 2013, 3:34:54 PM4/12/13
to rubyin...@googlegroups.com
On Linux and OSX [-1].pack("l!").size returns 4 for 32-bit rubies, and 8 for 64-bit rubies.

On Windows, it always returns 4. This includes a ruby I built from source using VC 2010
on a 64-bit Win 7 OS, as well as both the 32-bit and 64-bit 2.0.0p0 ruby installers.

This might be relevant:
I built two different versions of ruby_debug.so with the two 2.0.0 rubyinstaller rubies.
ruby 2.0/32 will load only the version built with 2.0/32, and 2.0/64 will load only
the version built with 2.0/64, which is good.

However, the mingw file utility tells me the 32-bit items are "PE32 executable for
MS Windows (console) Intel 80386 32-bit" while the 64-bit items are actually
"PE 32+ executable for MS Windows (console) Mono/.Net assembly".  So maybe
they aren't actually true 64-bit files?

This is on  Windows7 64-bit mode

Thanks,
Eric

Luis Lavena

unread,
Apr 12, 2013, 4:01:13 PM4/12/13
to rubyin...@googlegroups.com
On Fri, Apr 12, 2013 at 3:34 PM, Eric Promislow <eric.pr...@gmail.com> wrote:
On Linux and OSX [-1].pack("l!").size returns 4 for 32-bit rubies, and 8 for 64-bit rubies.
 
On Windows, it always returns 4. This includes a ruby I built from source using VC 2010
on a 64-bit Win 7 OS, as well as both the 32-bit and 64-bit 2.0.0p0 ruby installers.



 
This might be relevant:
I built two different versions of ruby_debug.so with the two 2.0.0 rubyinstaller rubies.
ruby 2.0/32 will load only the version built with 2.0/32, and 2.0/64 will load only
the version built with 2.0/64, which is good.


If ruby_debug packaged as gem? then the gem takes care of the platform for you, the only issue is the versioning (2.0 versus 1.9.3, etc)

For that you will need to package multiple gems.
 
However, the mingw file utility tells me the 32-bit items are "PE32 executable for
MS Windows (console) Intel 80386 32-bit" while the 64-bit items are actually
"PE 32+ executable for MS Windows (console) Mono/.Net assembly".  So maybe
they aren't actually true 64-bit files?

This is on  Windows7 64-bit mode


Not sure what you're using, but 64bit executables are PE32+, not PE64 as you might expect:


Cheers, 
-- 
Luis Lavena
AREA 17
-
Perfection in design is achieved not when there is nothing more to add,
but rather when there is nothing more to take away.
Antoine de Saint-Exupéry

Eric Promislow

unread,
Apr 12, 2013, 4:27:13 PM4/12/13
to rubyin...@googlegroups.com
Thanks, the wikipedia page explains what's going on.
I'll have to go by the platform, because there are no
pure pointers in Ruby code.


--
You received this message because you are subscribed to a topic in the Google Groups "RubyInstaller" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/rubyinstaller/KvE69YuFBe8/unsubscribe?hl=en.
To unsubscribe from this group and all its topics, send an email to rubyinstalle...@googlegroups.com.
To post to this group, send email to rubyin...@googlegroups.com.
Visit this group at http://groups.google.com/group/rubyinstaller?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Dušan D. Majkić

unread,
Apr 12, 2013, 5:24:54 PM4/12/13
to rubyin...@googlegroups.com
You can check for DL::SIZEOF_VOIDP == DL::SIZEOF_LONG_LONG

It checks if size of void*, whose size depends on 32/64bit ruby,
equals size of long long which is 64bits. So it's true for 64bit ruby,
and false for 32bit ruby.

This check is used in ruby core and should work cross-platform on all
Linux, OSX and Windows.
> --
> You received this message because you are subscribed to the Google Groups
> "RubyInstaller" group.
> To unsubscribe from this group and stop receiving emails from it, send an

Eric Promislow

unread,
Apr 13, 2013, 12:26:27 PM4/13/13
to rubyin...@googlegroups.com
Thanks, but it doesn't really solve the problem of knowing which library to open, because I have to do this in C.


You received this message because you are subscribed to a topic in the Google Groups "RubyInstaller" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/rubyinstaller/KvE69YuFBe8/unsubscribe?hl=en.
To unsubscribe from this group and all its topics, send an email to rubyinstalle...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages