Saturday 15 May 2010

Simple Ruby C extension cannot find ruby.h -


I wrote an incredibly simple extension for Ruby. .

  require: Unfortunately, this  ruby.h  can not  

The extconf.rb the "mkmf" $ srcs =% w {hypergeometric.c} $ objs =% w {hypergeometric} create_makefile ( "hypergeometric")

and here is the single source file:

  #include & lt; Ruby.h & gt; // has also tried to include "ruby.h", the same error is VALUE cHypergeometric; Zero Init_hypergeometric () {cHypergeometric = rb_define_module ("HyperGametric"); }   

When I try to compile it, I get the following error:

  ../../../../ ext / Haiprgemetrik /hypergeometric.c:1:18: error: ruby.h: no such file or directory   

Note that line numbers are off because I mostly out code instead It has commented on removal.

I do is interesting, if I try to compile without cleaning, then I get a different error:

  ld: warning: ignore Haiprojemetrik file to file had went designed for unsupported file format 0x67 0x70 0x63 0x68 0x43 0x30 0x31 0x33 0x38 0x4b 0x73 0x92 0x3d 0xf1 0xa5 0x62) which is not architecture being added (x86_64): hypergeometric   

(Full production is included in the summary again.)

Maybe this is a clue?

Why can not it get ruby.h ? When I compile or, both of these functions are corrected and there is no problem finding ruby.h . (For the record, I wrote NMatrix, C extension and everyone - and I think for somebody on this particular extension basis on extconf.rb )

the answer was astoundingly simple

I had a line in your extconf.rb :. $ objs =% W {hypergeometric} , which I copied from a different project, I found out that I remember the second half of the line:

  $ Objs =% w {hypergeometric} .map {| I | I + ".o"}   

I can not understand why this change may suddenly get it ruby.h .

Finally, this was a strange error message:

  ld: Warning: Unblock the file hypergmetric, the file was created for the unsupported file format (0x67 0x70 0x63 0x68 0x43 0x30 0x31 0x33 0x38 0x4b 0x73 0x92 0x3d 0xf1 0xa5 0x62) The architecture that has been added (x86_64): hypergemetric   

But weird it only the second Time is run I bundle app rake compile .

No comments:

Post a Comment