“致命错误:未找到'EXTERN.h'文件”在安装Perl模块时 [英] "Fatal error: 'EXTERN.h' file not found" while installing Perl modules

查看:454
本文介绍了“致命错误:未找到'EXTERN.h'文件”在安装Perl模块时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当尝试安装JSON :: XS或YAML :: XS之类的Perl模块时,我收到相同的错误:

While trying to install Perl modules like JSON::XS or YAML::XS, i receive the same error:


XS.xs:1: 10:致命错误:找不到 EXTERN.h文件

XS.xs:1:10: fatal error: 'EXTERN.h' file not found

我使用的是MacBook,xCode是最新的,其他所有可以帮助的事情都是

I use MacBook, xCode is up to date, everything else that could help is up to date too.

推荐答案

自OS X El Capitan以来,Apple推出了系统完整性保护,它限制了对/ usr / lib / usr / bin以及安装Perl安装所使用的其他敏感目录(甚至是root或sudo用户)的写入与操作系统捆绑在一起。在安装新模块以及尝试安装XS模块(那些链接到外部C库的模块)时,这可能会引起问题。

Since OS X El Capitan, Apple introduced System Integrity Protection which restricts writing to /usr/lib /usr/bin and other sensitive directories (even to root or sudo user) that are used by the installation of Perl bundled with the Operating System. This can cause issues when it comes to installing new modules and also if trying to install XS modules ( those linked to external C libraries ).

因此,您不应该考虑将默认的Perl安装作为有效的开发环境,尤其是在安装自定义模块时。

For this reason you should not consider the default Perl installation as a working development environment, especially if you are installing custom modules.

查看此PM线程和其他。自从El-Capitan设法通过使用tarball手动构建并添加一些参数或环境变量来设置路径来解决此问题之前,我认为最好保留使用Perl系统,但这不是走的路。这使您的环境难以构建,但又易碎且对操作系统更新敏感,后者可能以多种不同方式破坏事物。

Check out this thread on PM and others. I had since El-Capitan managed to solve this before by manually building from tarball and adding a few params or environment variables to set the paths believing that it would be best to retain use of the system Perl but this is not the way to go. This makes your environment difficult to build but also brittle and sensitive to OS updates that may either break things in many different ways.

最佳实践似乎始于Perl使用 brew install perl 并在此环境中工作,请记住要按照安装程序的指示设置bash_profile。

The best practice seems to be starting with a Perl using brew install perl and work in this environment, remembering to setup your bash_profile as directed by the installer.

还值得记住做一个 brew链接perl 。如果您收到有关这种破坏的警告,那么看上去好像系统的Perl库就不用担心了-这些很可能是您在顶部安装的模块,因此链接起来的麻烦将大大减少。如果您有疑问,请记下将清除哪些模块安装,并在配置环境后重新安装它们(即,使用 cpanm 或粘贴配置了模块安装程序方法使用旧的 perl -MCPAN -e shell 等)

Also worth remembering to do a brew link perl. If you receive warnings about this clobbering what looks like system Perl libraries don't worry - these are likely modules that were installed by you over the top and it will cause you less trouble to link over these. If you have concerns, make a note of which module installs will be cleared and re-install them once your environment is configured ( ie your module installer approach is configured using cpanm or sticking with the old perl -MCPAN -e shell etc)

brew的这种新Perl设置无需继续运行sudo会增加另一层可能会出错的环境,因为环境变量不会继续执行,并且会发生权限冲突等。

This new Perl setup from brew eliminates the need to continuing running sudo which adds another layer of things that can go wrong as environment variables don't follow through and permission conflicts arise etc.

最后,我建议简化软件包/模块的安装进行简装安装cpanminus 。如果您以前已经安装了此工具,则可以通过执行 brew重新安装cpanminus

Finally to simplify package/module installation I suggest doing a brew install cpanminus. If you had previously already installed this, you can ensure the paths etc are configured by doing a brew reinstall cpanminus

来确保路径等已配置。如果您想更进一步,那么还可以安装perlbrew,这将使您能够以用户身份运行多个版本的Perl,并使用其自己的库和模块来配置这些版本,这非常有用,尤其是在与您的版本保持一致的情况下。用于测试等的生产环境。

If you want to take it another step further then you can install perlbrew as well which will give you the ability to run multiple versions of Perl as your user and configure these with their own libs and modules which can be very useful particularly if aligning with your production environment for testing etc.

如果从系统Perl转向这种方法,您可能会遇到的一个问题是,需要处理使用sudo安装东西所带来的任何困扰。值得花一点时间来正确设置所有这些设置,并且您所遇到的问题将大大减少,并且您不会再有that琐的感觉,即您不想更改任何东西,因为担心一切都会破裂

One problem you may face if moving from system Perl to this kind of approach is needing to deal with any hangovers from installing things with sudo. It wis worth taking a little time to get all this set up right though and your issues going forward will be greatly reduced and you won't be left with that nagging feeling that you don't want to change anything for fear of it all breaking.

我也遇到过 Perl博客文章,该文章建议修复Mojave上Perlbrew的XS问题

要点描述了更新cpan shell安装根目录,尽管除非您的cpan这样做是不必要的在执行上述步骤后,卡在了旧的配置中。

This Gist described updating your cpan shell install root though this shouldn't be necessary unless your cpan is stuck in an old config after taking steps above.

我也将其作为新问题在 PerlMonks

I've also raised this as a new issue on PerlMonks

这篇关于“致命错误:未找到'EXTERN.h'文件”在安装Perl模块时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆