[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

comp.lang.ruby

Finding ruby.h

John Ky

1/14/2009 5:20:00 AM

[Note: parts of this message were removed to make it a legal post.]

Hi,

I'm building ruby extensions across many different OSes and architectures.

Does anyone know an easy way to find ruby.h on any given system?

I'm told that perl has a "perl -V" or @ENV variable which gives some paths I
can look through for perl.h.

Does Ruby have an equivalent? Is there a better way to find ruby.h?

Thanks,

-John

4 Answers

Jeremy Hinegardner

1/14/2009 5:45:00 AM

0

On Wed, Jan 14, 2009 at 02:20:00PM +0900, John Ky wrote:
> Hi,
>
> I'm building ruby extensions across many different OSes and architectures.
>
> Does anyone know an easy way to find ruby.h on any given system?
>
> I'm told that perl has a "perl -V" or @ENV variable which gives some paths I
> can look through for perl.h.
>
> Does Ruby have an equivalent? Is there a better way to find ruby.h?

This works on a couple of my systems:

require 'rbconfig'
loc = File.join( Config::CONFIG['archdir'], 'ruby.h')
if File.exist?( loc ) then
puts loc
else
puts "Unable to find ruby.h in #{loc}"
end

enjoy,

-jeremy

--
========================================================================
Jeremy Hinegardner jeremy@hinegardner.org


LaP

1/14/2009 4:57:00 PM

0

John Ky a écrit :

> I'm building ruby extensions across many different OSes and architectures.
>
> Does anyone know an easy way to find ruby.h on any given system?
>
> I'm told that perl has a "perl -V" or @ENV variable which gives some paths I
> can look through for perl.h.
>
> Does Ruby have an equivalent? Is there a better way to find ruby.h?

My first idea for this kind of problem would be to check GNU autoconf /
configure.sh

LaP

Dave Harrison

1/14/2009 5:11:00 PM

0

John Ky wrote:
> [Note: parts of this message were removed to make it a legal post.]
>
> Hi,
>
> I'm building ruby extensions across many different OSes and architectures.
>
> Does anyone know an easy way to find ruby.h on any given system?
>
> I'm told that perl has a "perl -V" or @ENV variable which gives some paths I
> can look through for perl.h.
>
> Does Ruby have an equivalent? Is there a better way to find ruby.h?
>
> Thanks,
>
> -John
>

I have used CMake to make a SWIG wrapper with success on Windows and
Linux. The FindRuby.cmake script does all of the hard work at locating
Ruby.h. CMake-2.6.2 (and possibly others) includes FindRuby.cmake and
can be used like so:

(Note: FindRuby.cmake doesn't export RUBY_FOUND, so I create that var
myself)

Main CMakeLists.txt:
....
SET(RUBY_FOUND FALSE)
FIND_PACKAGE( Ruby)
if(RUBY_INCLUDE_PATH AND RUBY_LIBRARY)
SET(RUBY_FOUND TRUE)
endif(RUBY_INCLUDE_PATH AND RUBY_LIBRARY)
....
if(RUBY_FOUND)
INCLUDE_DIRECTORIES( ${RUBY_INCLUDE_PATH})
endif(RUBY_FOUND)
....

CMakeLists.txt for each library in app:
....
if(RUBY_FOUND)
SET_SOURCE_FILES_PROPERTIES(RbDynamic.i PROPERTIES SWIG_FLAGS "-autorename")
SET_SOURCE_FILES_PROPERTIES(RbDynamic.i PROPERTIES CPLUSPLUS ON)
SET_SOURCE_FILES_PROPERTIES(RbDynamic.i PROPERTIES SWIG_FLAGS "-includeall")
SWIG_ADD_MODULE( rbdynamic ruby RbDynamic.i )
SWIG_LINK_LIBRARIES( rbdynamic ${RUBY_LIBRARY}
${MIIND_LIBRARY_PREFIX}dynamic
)
endif(RUBY_FOUND)
....

CMake is a doddle to use if you don't already know it, and is cross
platform (I've only used Windows and Linux). Check it out at www.cmake.org

Dave H.

John Ky

1/15/2009 4:53:00 AM

0

[Note: parts of this message were removed to make it a legal post.]

Hi all,

Thanks everyone for your help. I've settled with this solution as I've
already got it working. Very much appreciated!

-John

On Wed, Jan 14, 2009 at 4:44 PM, Jeremy Hinegardner
<jeremy@hinegardner.org>wrote:

> On Wed, Jan 14, 2009 at 02:20:00PM +0900, John Ky wrote:
> > Hi,
> >
> > I'm building ruby extensions across many different OSes and
> architectures.
> >
> > Does anyone know an easy way to find ruby.h on any given system?
> >
> > I'm told that perl has a "perl -V" or @ENV variable which gives some
> paths I
> > can look through for perl.h.
> >
> > Does Ruby have an equivalent? Is there a better way to find ruby.h?
>
> This works on a couple of my systems:
>
> require 'rbconfig'
> loc = File.join( Config::CONFIG['archdir'], 'ruby.h')
> if File.exist?( loc ) then
> puts loc
> else
> puts "Unable to find ruby.h in #{loc}"
> end
>
> enjoy,
>
> -jeremy
>
> --
> ========================================================================
> Jeremy Hinegardner jeremy@hinegardner.org
>
>
>