我正在为 Ruby 编写 C 扩展,并且在 extconf.rb 文件中有类似的内容:
if(not have_library('z'))
$stderr << "Error, could not locate zlib.\n"
abort "Missing zlib"
end
因此,如果缺少 zlib,安装过程将中止。相反,由于我的扩展可以在没有 zlib 的情况下使用 AND,我想做如下的事情;
if(have_library('z'))
# do something so that -DHAVE_ZLIB is passed to the compiler
# when compiling the extension.
end
我怎样才能做到这一点?
编辑:问题在于 if...end 语句中的注释:如何为编译器添加 -DHAVE_ZLIB 定义?