Forum: JRuby Jruby-1.6 and FFI (and GLPK)

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
7ece60b3b5bb235d1b6df89727ca6cf7?d=identicon&s=25 Maurice Diamantini (Guest)
on 2008-12-18 08:34
(Received via mailing list)
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
Ede2aa10c6462f1d825143879be59e38?d=identicon&s=25 Charles Oliver Nutter (Guest)
on 2008-12-18 16:58
(Received via mailing list)
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 :)

- Charlie

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email
7ece60b3b5bb235d1b6df89727ca6cf7?d=identicon&s=25 Maurice Diamantini (Guest)
on 2008-12-24 00:47
(Received via mailing list)
2008/12/18 Charles Oliver Nutter <charles.nutter@sun.com>:
> .... 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 ...:)

> 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...

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 :)
>
> - Charlie

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email
This topic is locked and can not be replied to.