我有一个小项目的ruby扩展,它是这样组织的:
./
Rakefile
ext/
mymodule/
extconf.rb
mymodule.rb
mymodule.cpp
source1.h
source1.cpp
source2.h
source2.cpp一切都正常,但是我需要把一些源文件放到一个目录中(我在一个git repos中创建/修改/测试所有这些源文件,以便在测试我的C++代码时只需要更新这个目录)。因此,新组织看起来如下所示:
./
Rakefile
ext/
mymodule/
extconf.rb
mymodule.rb
mymodule.cpp
somesourcesfiles/
source1.h
source1.cpp
source2.h
source2.cpp我现在的问题是如何向extconf.rb指定在何处查找源文件(extconf.rb默认使用当前目录中的源文件)。
我已经在extconf.rb白化成功中进行了测试:
myfiles = %w{somesourcefiles/source1 somesourcefiles/source2 mymodule}
$srcs = myfiles.map{|i| i + ".cpp"}我收到一条错误消息,说链接器找不到一些".o“文件,所以我添加了以下内容:
myfiles = %w{somesourcefiles/source1 somesourcefiles/source2 mymodule}
$srcs = myfiles.map{|i| i + ".cpp"}
$objs = myfiles.map{|i| i + ".o"}但这并不管用。
发布于 2019-06-07 00:21:20
请参阅mkmf ignores files in sub-folders when it compiles the C extension
$INCFLAGS << " -I$(srcdir)/somesourcesfiles"
$VPATH << "$(srcdir)/somesourcesfiles"https://stackoverflow.com/questions/25947387
复制相似问题