[Stellar-discuss] f95 + c + Ruby = okay on Mac. But what about
linux?
Evert Glebbeek
E.Glebbeek at phys.uu.nl
Tue Nov 29 10:05:51 GMT 2005
> 2) There are 2 ways to use "low-level" code (i.e., c, c++, f77, or
> f95) in Ruby (or in Python for that matter). My preference (and what
> I did in Tioga) was to make an "extension" that is basically a
> dynamically loadable library. The other alternative is to "embed"
> the Ruby interpreter in some other program. I've had to go with this
> second approach in order to get the Fortran runtime set up properly.
Probably the best idea anyway: we don't want to bother too much with
installing shared objects (or dynamical libraries, depending on what language
you speak) as normal users. Can be done, but I find it rather annoying.
Besides, MacOS X handles dynamical libraries slightly differently from other
UNIX systems, which probably doesn't help portability either!
> 5) You need to tell cfortran.h which fortran compiler you are using
> so it can produce correct wrappers. I've been able to make it work
> on the Mac with gcc and the Absoft ProFortran compiler, but not with
> the IBM xlf compiler (at least not yet).
I've tried f2c for boith the Intel compiler and the Lahey compiler (the ones I
have installed here).
> Here's a tar file with the toy example I've been playing with. If
> you're on a Mac and looking for a way to waste some time, you might
> try it. If you're running linux, it would be nice to know if this
> arrangement can be made to work there for some combination of C and
> f95 compilers.
I had to install Ruby (on my local account) because the installation we had
available wasn't suitable.
From the RUBY_LIB = line I've had to remove the ObjectiveC runtime (that's
what I assume -lobjc includes anyway). Is this nescessary on the Mac? As long
as you're not using ObjectiveC features it if probably best left out. I've
also had to change -lruby to -lruby-static, which I assume is just a
difference in the way Ruby is installed.
Unfortunately, that's about as far as my success story goes...
Using the Intel compiler, I get
glebbeek at siu024: ~/Program/cfort/cfortran>make
gcc -g -c -Df2c -I/home/strknd/glebbeek/lib/ruby/1.8/i686-linux -c cfun_main.c
gcc -g -c -Df2c -I/home/strknd/glebbeek/lib/ruby/1.8/i686-linux -c
cfun_select.c
ifort -g -c ffun_data_mod.f
ifort -g -c ffun_mod.f
ifort -g -c ffun_select.f
ifort -o fun cfun_main.o cfun_select.o ffun_data_mod.o ffun_mod.o
ffun_select.o -L/home/strknd/glebbeek/lib/ruby/1.8/i686-linux -lruby-static
-ldl
cfun_main.o(.text+0x12e): In function `main':
/home/strknd/glebbeek/Program/cfort/cfortran/cfun_main.c:29: multiple
definition of `main'
/usr/local/intel_fc_80/lib/for_main.o(.text+0x0): first defined here
ld: Warning: size of symbol `main' changed from 42
in /usr/local/intel_fc_80/lib/for_main.o to 415 in cfun_main.o
/usr/local/intel_fc_80/lib/for_main.o(.text+0x1c): In function `main':
: undefined reference to `MAIN__'
/home/strknd/glebbeek/lib/libruby-static.a(string.o)(.text+0x4f2e): In
function `rb_str_crypt':
/home/strknd/glebbeek/Program/Ruby/ruby-1.8.3/string.c:4360: undefined
reference to `crypt'
make: *** [fun] Error 1
glebbeek at siu024: ~/Program/cfort/cfortran>
and with the Lahey compiler (basically the same error)
glebbeek at siu024: ~/Program/cfort/cfortran>make
gcc -g -c -Df2c -I/home/strknd/glebbeek/lib/ruby/1.8/i686-linux -c cfun_main.c
gcc -g -c -Df2c -I/home/strknd/glebbeek/lib/ruby/1.8/i686-linux -c
cfun_select.c
lf95 -g -c ffun_data_mod.f
Encountered 0 errors, 0 warnings in file ffun_data_mod.f.
lf95 -g -c ffun_mod.f
Encountered 0 errors, 0 warnings in file ffun_mod.f.
lf95 -g -c ffun_select.f
Encountered 0 errors, 0 warnings in file ffun_select.f.
lf95 -o fun cfun_main.o cfun_select.o ffun_data_mod.o ffun_mod.o ffun_select.o
-L/home/strknd/glebbeek/lib/ruby/1.8/i686-linux -lruby-static -ldl
cfun_main.o(.text+0x12e): In function `main':
/home/strknd/glebbeek/Program/cfort/cfortran/cfun_main.c:29: multiple
definition of `main'
/usr/local/lf9562/bin/../lib/fj90rt0.o(.text+0x0): first defined here
/usr/bin/ld: Warning: size of symbol `main' changed from 70
in /usr/local/lf9562/bin/../lib/fj90rt0.o to 415 in cfun_main.o
/usr/bin/ld: cannot find -lruby-static
make: *** [fun] Error 1
Both of these are on Fedore Core 3 on an i686 system. I tried installing Ruby
on my other system (an AMD 64 running Gentoo Linux) but there's an error
during the installation that I can't figure out right now. I'll have a closer
look later. Since I'm running the Intel compiler there as well, I suspect
I'll have the same problem though...
Evert
--
Evert Glebbeek, PhD student
Physics and Astronomy Department, Utrecht University
Buys Ballot Laboratory, room 762
e-mail: glebbeek at astro.uu.nl tel. +31 (0)30 253 5235
www: http://www.phys.uu.nl/~glebbeek/
More information about the stellar-discuss
mailing list