【问题标题】:Compiling perl Net::Interface module on CentOS 8.1 fails在 CentOS 8.1 上编译 perl Net::Interface 模块失败
【发布时间】:2020-05-05 05:19:17
【问题描述】:

我下载了源代码并手动尝试编译 perl Net::Interface 模块。使用 CPAN 安装模块会出现同样的错误。

wget http://search.cpan.org/CPAN/authors/id/M/MI/MIKER/Net-Interface-1.016.tar.gz
tar xvfz Net-Interface-1.016.tar.gz
cd Net-Interface-1.016
perl Makefile.PL

现在失败并出现以下错误

checking for getnameinfo... yes
checking whether byte ordering is bigendian... no
checking for uint8_t... yes
checking size of uint8_t... configure: error: cannot compute sizeof (uint8_t)
See `config.log' for more details.
could not open config.h

config.log 显示以下错误

configure:10128: result: yes
configure:10135: checking size of uint8_t
configure:10437: gcc -o conftest -g -O2  -Wl,-z,relro -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -fstack-protector-strong -L/usr/local/lib  conftest.c  >&5
/usr/bin/ld: /tmp/ccXH6miX.o: relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a PIE object; recompile with -fPIC
/usr/bin/ld: final link failed: Nonrepresentable section on output
collect2: error: ld returned 1 exit status
configure:10440: $? = 1
configure: program exited with status 1
configure: failed program was:
| /* confdefs.h.  */
| #define PACKAGE_NAME ""
| #define PACKAGE_TARNAME ""
| #define PACKAGE_VERSION ""

如何解决此错误? config.log 似乎建议传递“-fPIC”标志,但我不确定如何?

谢谢。

【问题讨论】:

  • 您是否通过yumdnf 包管理器验证了此perl 模块不可用?
  • 有趣的是,在 Ubuntu 20.04 上,稍后在 configure 脚本中安装会失败。这个问题有一个解决方法here
  • @PolarBear 此模块不能作为 CentOS/RHEL 存储库(通过 yum/dnf)的 rpm 包提供。这就是为什么我不得不求助于构建模块。
  • @shustfo -- 如果包不可用,那么从源代码编译是唯一的解决方案。看起来error: cannot compute sizeof (uint8_t) 可能是问题的根源。可能是您需要安装一些开发包。链接器尝试组装二进制文件,但缺少某些内容。
  • @shustfo -- 文件 Changes 最后一次更新是在 2016 年 9 月 23 日。从那时起,一些头文件/开发文件有可能移动

标签: perl centos8


【解决方案1】:
/usr/bin/ld: /tmp/ccXH6miX.o: relocation R_X86_64_32 against
  `.rodata.str1.1' can not be used when making a PIE object; recompile with -fPIC
/usr/bin/ld: final link failed: Nonrepresentable section on output
collect2: error: ld returned 1 exit status

由于某种原因,配置脚本需要使用--enable-shared 运行(在 Ubuntu 上不需要)。以下内容在 CentOS 8 的 docker 容器中为我工作:

./configure --enable-shared
perl -I. Makefile.PL
make
sudo make install

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-10-02
    • 2019-09-23
    • 1970-01-01
    • 2013-12-01
    • 1970-01-01
    相关资源
    最近更新 更多