Jruby-1.6 and FFI (and GLPK)


#1

Bonjour à tous !

Thank you for putting FFI in JRuby.

If I understand well it’s new possibility, it would allow me
to use native C extension (perhaps C++ later ?) directly from
a JRuby script as well as a standard Ruby script without writing
one C line of code !

This would made Java a great solution for scientific programming.
But for now I have two questions/remarks
(Nothing urgent, just validation for potencial use of scientific library
from java world…)

1 - when I run the ffi examples locates in "jruby-1.1.6/samples/ffi/’
directory, all but one scripts seems to work as expected:

jruby gettimeofday.rb
=> nothing is display.
it seems that the require ‘rubygems’ line is bloquing
All works if I comment this line.

2 - I’d like to test JRuby/FFI with the GLPK library (Gnu Linear
Programming Toolkit)
This library is installed in a user location, and the folowing
(unix Leopart) environment variables are set :
GLPK_INCLUDE
GLPK_LIB
What header line should I put into a script for using GLPK from JRuby
?

Also I hope that future version of standard Ruby also include ffi
extension!

– Maurice


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

#2

Maurice Diamantini wrote:

Bonjour à tous !

Thank you for putting FFI in JRuby.

If I understand well it’s new possibility, it would allow me
to use native C extension (perhaps C++ later ?) directly from
a JRuby script as well as a standard Ruby script without writing
one C line of code !

That’s the idea! And hopefully at the same time ending the need for
writing C-based extensions to standard Ruby that can’t ever work on
other impls.

1 - when I run the ffi examples locates in "jruby-1.1.6/samples/ffi/’
directory, all but one scripts seems to work as expected:

jruby gettimeofday.rb
=> nothing is display.
it seems that the require ‘rubygems’ line is bloquing
All works if I comment this line.

Thanks for the update; I’ll fix it in the repository. I believe there
are additional examples in the ruby-ffi project on kenai:

http://kenai.com/projects/ruby-ffi

2 - I’d like to test JRuby/FFI with the GLPK library (Gnu Linear
Programming Toolkit)
This library is installed in a user location, and the folowing
(unix Leopart) environment variables are set :
GLPK_INCLUDE
GLPK_LIB
What header line should I put into a script for using GLPK from JRuby ?

Those two environment vars will be useful only if you need to map
structs out of the original .h files and if the GLPK_LIB location is not
in your normal LD paths. FFI does not actually compile any C code to
load the libraries, so if you can see the library and map the structs
appropriately, you are ready to go.

Also I hope that future version of standard Ruby also include ffi extension!

Me too :slight_smile:

  • Charlie

To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

#3

2008/12/18 Charles Oliver N. removed_email_address@domain.invalid:

… I believe there are
additional examples in the ruby-ffi project on kenai:

http://kenai.com/projects/ruby-ffi

Thanks, these exemples were very helpfull (but difficult to make a
readable print document …:slight_smile:

normal LD paths. FFI does not actually compile any C code to load the
libraries, so if you can see the library and map the structs appropriately,
you are ready to go.

Thanks to the exemple, I’ve been able to write a minimaliste interface
for running the exemple provided with the glpk doc.
The archive (wich also contains so C version and some remarks are
available at:

http://www.ensta.fr/~diam/ocro/projets/tdplne/ruby/ffi-glpk.tbz

It work better with jruby than with ruby (install pb??) but it’s not
very important for now.

Also, I read there was some problems for using FFI with C++ libraries
(I hope it will be solved).
But how about fortran library? Will FFI work with fortran some day?
If so, all mathematic fortran libraries could be use from Jruby.

And last, I heard a question about using glpk from java, does FFI allow
some binding between C and Java (without (or with a minimalist) Jruby
library?

Thank you very much,
– Maurice,

Also I hope that future version of standard Ruby also include ffi
extension!

Me too :slight_smile:

  • Charlie

To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email