鉴于我正在使用 Module::Build 来构建我的 perl 模块,我想在 Build.PL 中测试特定的系统库先决条件,如果未找到它们,则退出并显示错误。这似乎是确保调用编译器时满足必要先决条件的最佳方法。我可以让编译在链接时失败,但我认为在构建之前进行检测更好。这可能只是搜索构建系统在编译时将使用的相同 lib 目录的问题,但我希望 Module::Build 中有一些功能可以帮助解决这个问题。
具体来说,在我的例子中,我想验证 libicu 是否已安装并且在编译器使用的 libpath 中可用。
Given that I'm using Module::Build to build my perl module, I'd like to test for specific system library prerequisites in my Build.PL and exit with an error if they are not found. This seems like the best way to ensure that the necessary prerequisites will be met when the compiler is called. I could just let the compilation fail when it links, but I think detecting prior to building is better. It's probably a matter of just searching the same lib directories that the build system will use when compiling, but I'm hoping there is some functionality in Module::Build that could help figure this out.
To be specific, in my case I want to verify that libicu is installed and available in the libpath used by the compiler.
发布评论
评论(2)
听起来您正在寻找 Devel::CheckLib。 (还有 ExtUtils::PkgConfig 用于使用
pkg-config
报告配置详细信息。)顺便说一句,Build.PL 报告非 Perl 模块先决条件不可用的标准方法是打印一条消息,解释什么是丢失,然后
退出 0
没有调用create_build_script
。 Devel::CheckLib 提供了一个check_lib_or_exit
函数来执行此操作。It sounds like you're looking for Devel::CheckLib. (There's also ExtUtils::PkgConfig for libraries that use
pkg-config
to report configuration details.)BTW, the standard way for Build.PL to report that a non-Perl-module prerequisite is not available is for it to print a message explaining what's missing and then
exit 0
without callingcreate_build_script
. Devel::CheckLib provides acheck_lib_or_exit
function for doing that.我通常的方法是使用 ExtUtils::PkgConfig 如果它是
pkg -config
基于库,或 ExtUtils::CChecker 用于检查更困难的事情,例如不使用pkg-config
的旧库,或更微妙的操作系统功能和功能。My usual approach is to use ExtUtils::PkgConfig if it's a
pkg-config
based library, or ExtUtils::CChecker to check for more difficult things, such as older libraries that don't usepkg-config
, or more subtle OS features and abilities.