Error compiling with rubyinline

Dear Rubyists,

I am encountering trouble compiling with RubyInline. Inside rubyinline
there is a construction of the command to create the library file:

cmd = "#{Config::CONFIG['LDSHARED']} #{flags}
#{Config::CONFIG['CFLAGS']} -I #{hdrdir} -o #{so_name} #{src_name}
#{libs}" [line 368 in inline.rb]

On my machine/installation this command fails with:

Building /users/obroeker/.ruby_inline/Inline_Example_58ed.so with
'/apps/gnu/bin/ld -shared -g -O2 -I
/users/obroeker/lib/ruby/1.8/mips-irix6.5 -o
/users/obroeker/.ruby_inline/Inline_Example_58ed.so
/users/obroeker/.ruby_inline/Inline_Example_58ed.c '
/users/obroeker/.ruby_inline/Inline_Example_58ed.c: file not
recognized: File format not recognized

which seems logical to me, because the construction of the command
includes the src_name of the file and thus assumes that the whole
compilation is also done in this command. If I would have written this,
I would have had two parts: one for compiling, one for linking. Can it
be done in one step with ld? Must be so, otherwise the code would have
never worked. Unfortunately I have found no way by hand to do all at
the same time.

Thanks for any help.

greetings, Oliver

Dear Rubyists,

I am encountering trouble compiling with RubyInline. Inside rubyinline
there is a construction of the command to create the library file:

cmd = "#{Config::CONFIG['LDSHARED']} #{flags}
#{Config::CONFIG['CFLAGS']} -I #{hdrdir} -o #{so_name} #{src_name}
#{libs}" [line 368 in inline.rb]

On my machine/installation this command fails with:

Building /users/obroeker/.ruby_inline/Inline_Example_58ed.so with
'/apps/gnu/bin/ld -shared -g -O2 -I
/users/obroeker/lib/ruby/1.8/mips-irix6.5 -o
/users/obroeker/.ruby_inline/Inline_Example_58ed.so
/users/obroeker/.ruby_inline/Inline_Example_58ed.c '
/users/obroeker/.ruby_inline/Inline_Example_58ed.c: file not
recognized: File format not recognized

which seems logical to me, because the construction of the command
includes the src_name of the file and thus assumes that the whole
compilation is also done in this command. If I would have written this,
I would have had two parts: one for compiling, one for linking. Can it
be done in one step with ld? Must be so, otherwise the code would have
never worked. Unfortunately I have found no way by hand to do all at
the same time.

Which platform are you on?

RubyInline (and also my Ruby2CExtension) assumes that Config::CONFIG["LDSHARED"] is set to something like "gcc -shared", e.g. on my system:

Config::CONFIG["LDSHARED"]

=> "i686-pc-linux-gnu-gcc -shared"

If that is the case, then compilation in one step works. But as you show, this doesn't seem to always be the case.

So again, what platform are you on and did you supply any unusual options when building Ruby.

Dominik

ยทยทยท

On Mon, 28 Aug 2006 16:45:18 +0200, OliverMarchand <oliver.marchand@gmail.com> wrote:

Dominik Bathon schrieb:

Which platform are you on?

RubyInline (and also my Ruby2CExtension) assumes that
Config::CONFIG["LDSHARED"] is set to something like "gcc -shared", e.g. on
my system:

>> Config::CONFIG["LDSHARED"]
=> "i686-pc-linux-gnu-gcc -shared"

If that is the case, then compilation in one step works. But as you show,
this doesn't seem to always be the case.

That value was set to ld -shared in my case, which does not compile. I
didn't know that gcc can produce shared libraries. I simply changed
"ld" to "gcc" and volia, it works.

Thanks!

ciao, Oliver