mkmf 编译 C 扩展时会忽略子文件夹中的文件
我想像这样组织 C 源代码:
+ /
|
|___ + ext
| |
| |___ + native_extension
| |
| |___ + lib
| | |
| | |___ (Source files are kept in here - may contain sub-folders)
| |
| |___ native_extension.c
| |___ native_extension.h
| |___ extconf.rb
|
|___ + lib
| |
| |___ (Ruby source code)
|
|___ Rakefile
我无法让此设置与 mkmf
一起正常工作。 native_extension/lib
中的文件(由 native_extension.c
包含)将被完全忽略。
当我构建扩展时,仅编译 native_extension.{h,c}
,并且我得到一个不完整的 native_extension.{so,dll}
,这会在以下情况下给我带来符号查找错误:我尝试运行它。
有办法让这个工作吗?
I'd like to organize the C source code like this:
+ /
|
|___ + ext
| |
| |___ + native_extension
| |
| |___ + lib
| | |
| | |___ (Source files are kept in here - may contain sub-folders)
| |
| |___ native_extension.c
| |___ native_extension.h
| |___ extconf.rb
|
|___ + lib
| |
| |___ (Ruby source code)
|
|___ Rakefile
I'm having trouble getting this setup to work correctly with mkmf
. The files in native_extension/lib
, which are included by native_extension.c
, are being completely ignored.
When I build the extension, only native_extension.{h,c}
are compiled, and I get an incomplete native_extension.{so,dll}
that gives me symbol lookup errors when I try to run it.
Any way to make this work?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以通过“extconf.rb”使用其他文件夹中的源文件,如下所示:
You can use source files from another folders with "extconf.rb" like this:
虽然您可以将第二个参数传递给
make_makefile
来指定不同的源目录(例如,make_makfile('native_extension', 'lib')
),但这会导致它不包含您的native_extension.c
文件。查看 mkmf.rb 的源代码,除了自己重写生成的 Makefile 之外,似乎没有任何方法可以使其在两个地方都可见。While you can pass a second argument to
make_makefile
to specify a different source directory (e.g.,make_makfile('native_extension', 'lib')
), that would cause it not to include yournative_extension.c
file. Looking at the source for mkmf.rb, it doesn't appear there's any way to make it look in both places short of rewriting the generated Makefile yourself.