如何从 Makefile.PL 中找到 C 库头文件?
如何从 Makefile.PL 中找到 C 库头文件?
有 ExtUtils::Liblist 来查找库,但我看不到头文件的等效项。
How can I locate a C library header file from a Makefile.PL?
There is ExtUtils::Liblist to find libraries, but I can't see the equivalent for header files.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Devel::CheckLib
是大多数作者的样子用于此。它检查库和头文件是否存在,因为如果没有它们,这些库可能毫无用处。Devel::CheckLib
is what most authors seem to be use for that. It checks both for the existance of libraries as well as header files, as those libraries are probably useless without them.为什么不编写一个小库来执行此操作(并让它存在于 inc/lib/FindHeaders.pm 或包目录顶层下的某个类似库中)。只需使用 Config(请参阅 incpath)以及 File::Find 和 glob,您应该能够拥有一个小型库,它可以遍历您的默认包含路径并映射系统上头文件的哈希值,将其返回到 Makefile 的调用.PL。将其扩展为包括非标准包含路径以及库的构造函数参数将是微不足道的。简单易行。
Why not write a small lib to do this (and let it live in inc/lib/FindHeaders.pm or some such under the top level of your package dir). Just use Config (see incpath) along with File::Find and glob and you should be able to have a small library which can walk your default include path and map a hash of header files on your system, returning it to a call from Makefile.PL. It would be trivial to extend this to include non-standard include paths as well with a constructor argument to your lib. Easy peasy.