关于perl语言的环境问题

我用的虚拟机是Redhat6.7,应该是自带了perl 5.10.1,可是我在实际做项目的时候发现报错缺少YAML模块。 我的/usr/local/bin目录下确实是由perl的执行文件,但是/usr/local/lib下并没有perl的库,所以打算重新安装一下perl。
从官网下载到perl源码以后,执行命令

     tar -xzf perl-5.x.y.tar.gz  # 解压
     cd perl-5.30.2
     ./Configure -des -Dprefix=$HOME/localperl #指定目录安装
     make
     make test
     make install

这里需要注意几点:

  1. 是最好指定目录安装,默认安装目录在没有root权限的情况下后续根本无法安装模块。
  2. make报错,具体报错如下:
IO.xs: In function ‘XS_IO__Poll__poll’:
IO.xs:249: error: invalid application of ‘sizeof’ to incomplete type ‘struct pollfd’ 
IO.xs:253: error: invalid use of undefined type ‘struct pollfd’
IO.xs:253: error: dereferencing pointer to incomplete type
IO.xs:255: error: invalid use of undefined type ‘struct pollfd’
IO.xs:255: error: dereferencing pointer to incomplete type
IO.xs:257: error: invalid use of undefined type ‘struct pollfd’
IO.xs:257: error: dereferencing pointer to incomplete type
IO.xs:261: error: invalid use of undefined type ‘struct pollfd’
IO.xs:261: error: dereferencing pointer to incomplete type
IO.xs:262: error: invalid use of undefined type ‘struct pollfd’
IO.xs:262: error: dereferencing pointer to incomplete type

这个问题在有老外给出过解答,这里粘贴一下原文,并且谈一下我的理解。
I just ran into this same problem and tracked down the root cause: the C_INCLUDE_PATH environment variable. Mine happened to be set as follows:

% printenv C_INCLUDE_PATH
C_INCLUDE_PATH=/home/me/REDACTED/include:

This came from a login script somewhere that was doing something like:

export C_INCLUDE_PATH=$HOME/REDACTED/include:$C_INCLUDE_PATH

while setting up my environment. That looks correct at first glance; unfortunately, it seems to be the case that foo: is equivalent to foo:. in this context-- that is, the empty string in that two-item colon-separated list seems to be implicitly treated the same as … Which effectively adds the current directory to the system include path, which makes #include <poll.h> do the same thing as #include “poll.h”, which is bad.
In Perl’s case, the rogue include path causes Perl’s poll.h to include itself instead of /usr/include/poll.h. Since Perl’s poll.h has a guard against multiple inclusion, the second include silently does nothing, and you end up with no poll.h at all, which quickly leads to the compiler error we both saw. This also explains why your patch makes the problem go away: there is no ./sys/poll.h in the build directory, so the compiler ends up finding /usr/include/sys/poll.h, which ultimately happens to be what you wanted.
My solution was to get rid of the stray colon in C_INCLUDE_PATH. In my case, I found the script that was setting it incorrectly and fixed it so that it explicitly checks for the case where the previous C_INCLUDE_PATH was empty, and not add a colon in that case. Of course, as a quick one-off fix, I could also have manually run export C_INCLUDE_PATH=/home/me/REDACTED/include or just unset C_INCLUDE_PATH before building Perl.
应该是路径包含的问题,解决办法比较简单
unset C_INCLUDE_PATH就可以成功make。
别忘了将perl的bin路径添加到环境变量中去。

export PATH=your_install_perl/bin:$PATH
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值