2

I have a little projet of a ruby extension which was organized like this :

./
  Rakefile
  ext/
    mymodule/
      extconf.rb
      mymodule.rb
      mymodule.cpp
      source1.h
      source1.cpp
      source2.h
      source2.cpp

Everything worked but I needed to put some of the source files in a directory (I create/modify/test all those source files in a git repos in order to just have to update this directory when my C++ code is tested). So the new organization looks like this :

./
  Rakefile
  ext/
    mymodule/
      extconf.rb
      mymodule.rb
      mymodule.cpp
      somesourcesfiles/
          source1.h
          source1.cpp
          source2.h
          source2.cpp

My problem now is how to specify to extconf.rb where to find the source files (extconf.rb use source files in current directory by default).

I have tested this in the extconf.rb whitout success:

myfiles = %w{somesourcefiles/source1 somesourcefiles/source2 mymodule}
$srcs = myfiles.map{|i| i + ".cpp"}

I have had an error message saying that the linker couldn't find some ".o" files so I added this:

myfiles = %w{somesourcefiles/source1 somesourcefiles/source2 mymodule}
$srcs = myfiles.map{|i| i + ".cpp"}
$objs = myfiles.map{|i| i + ".o"}

But this didn't work.

cedlemo
  • 3,205
  • 3
  • 32
  • 50

1 Answers1

0

See mkmf ignores files in sub-folders when it compiles the C extension

$INCFLAGS << " -I$(srcdir)/somesourcesfiles"
$VPATH << "$(srcdir)/somesourcesfiles"
puchu
  • 3,294
  • 6
  • 38
  • 62