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

Compiling perl Net::Interface module on CentOS 8.1 fails

我下载了源代码并尝试手动编译 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