在 FreeBSD 上使用 Rake 在 dep_selector Ruby gem 中编译 C 扩展
我正在尝试安装 Ruby gem:dep_gecode
。它编译一些 C 扩展,但编译失败,因为 cpp 编译器未使用正确设置的包含文件夹运行。
当我运行 rake install 时,它会自动从 extconf.rb 创建一个 Makefile 来编译扩展。当我编辑 Makefile 并手动添加标志 -I/usr/local/include
时,扩展的编译成功。但是当我重新运行 rake install 时,Makefile 会被覆盖,编译再次失败。显然我需要修复 extconf.rb 但我不太知道如何修复。
现在有更多细节。 dep_gecode
gem 的来源在这里:
https://github.com/opscode/ dep-selector
需要更改的extconf.rb
文件在这里:
https://github.com/opscode/dep-selector/blob /master/ext/dep_gecode/extconf.rb
我想在生成的 Makefile 中更改的是这一行:
CPPFLAGS = -I/usr/include -I/usr/include -I/usr/local/include
而不是此时正在生成的这一行:
CPPFLAGS = -I/usr/include -I/usr/include
如您所见,包含路径/usr/local/include
丢失。这是 FreeBSD 系统上的标准包含路径,这表明问题可能出在 Rake 上,而不是出在这个特定的 extconf.rb
文件上。 非常感谢任何帮助。
编辑:我刚刚找到了解决方法。将此行添加到 extconf.rb 即可使该文件夹正确出现在生成的 Makefile 中:
$CPPFLAGS << "-I/usr/local/include"
不确定这是否是处理此问题的正确方法尽管...
I am trying to install Ruby gem: dep_gecode
. It compiles some C extensions, but the compilation fails because the cpp compiler isn't run with properly set include folders.
When I run rake install
it automatically creates a Makefile from extconf.rb
to compile the extensions. When I edit the Makefile and manually add flag -I/usr/local/include
the compilation of the extensions succeeds. But when I re-run rake install
the Makefile gets overwritten and compilation fails again. Obviously I need to fix extconf.rb
but I don't quite know how.
Now a bit more details. The source for dep_gecode
gem is here:
https://github.com/opscode/dep-selector
The extconf.rb
file that needs to be changed is here:
https://github.com/opscode/dep-selector/blob/master/ext/dep_gecode/extconf.rb
What I want to change in the generated Makefile is this line:
CPPFLAGS = -I/usr/include -I/usr/include -I/usr/local/include
instead of this one, which is being generated at this moment:
CPPFLAGS = -I/usr/include -I/usr/include
As you see, the include path /usr/local/include
is missing. This is a standard include path on FreeBSD systems, which suggests that the problem may be with Rake, not with this particular extconf.rb
file.
Any help greatly appreciated.
Edit: I've just found a workaround. It is enough to add this line to extconf.rb
to have that folder properly appearing in the generated Makefile
:
$CPPFLAGS << "-I/usr/local/include"
Not sure if this would be the right way of dealing with this problem though...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论