perl - 在 CentOS 8.1 上编译 perl Net::Interface 模块失败

标签 perl centos8

我下载了源代码并尝试手动编译 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”标志,但我不确定如何传递?

谢谢。

最佳答案

/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

关于perl - 在 CentOS 8.1 上编译 perl Net::Interface 模块失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61597959/

相关文章:

Perl:不推荐使用哈希作为引用

perl - 为什么在内部范围内重新声明变量时 perl 不发出警告?

regex - Perl 正则表达式删除除最后一次出现之外的所有内容

pdo - Centos 8、PHP 7.2 和 MS SQL Server

docker - CentOS 8 Docker 容器中的 who 和 w 命令

node.js - nodejs 应用程序工作,但 nginx 代理没有捕捉到它

PM2 在 centos 8 上每 90 秒就会被杀死一次

perl - 从 Perl 中的散列中获取具有最高值的键的最简单方法是什么?

PHP 安装 : Error: It is not possible to switch enabled streams of a module

perl - 如何在我的 Heroku/Perl Web 应用程序中使用自定义模块?