3

I download the sources and manually tried to compile the perl Net::Interface module. Using CPAN to install the module gives the same error.

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

Now this fails with the below error

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 shows the below error

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 ""

How can I fix this error? config.log seems to suggest to pass "-fPIC" flag but I am not sure how?

Thanks.

sthustfo
  • 1,209
  • 4
  • 19
  • 35
  • Have you verified that this perl module is not available through `yum` or `dnf` package managers? – Polar Bear May 04 '20 at 19:05
  • Interestingly, on Ubuntu 20.04 the installation fails a little bit later in the `configure` script. That issue has a workaround [here](https://rt.cpan.org/Public/Bug/Display.html?id=124582) – Håkon Hægland May 04 '20 at 19:19
  • @PolarBear This module is not available as a rpm package from CentOS/RHEL repositories (through yum/dnf). That's why I had to resort to building the module. – sthustfo May 04 '20 at 19:24
  • @sthustfo -- If the package is not available, then compilation from the source is only solution. It looks like `error: cannot compute sizeof (uint8_t)` may be the source of the problem. It might be that you need to install some development package. Linker attempts to assemble binary file and something is missing. – Polar Bear May 04 '20 at 19:34
  • @sthustfo -- File [Changes](https://metacpan.org/changes/distribution/Net-Interface) was last time updated on Sep 23, 2016. There is a chance that some header/development files was _moved around_ since then. – Polar Bear May 04 '20 at 19:43
  • @PolarBear I agree with your analysis, but unable to pin point what could have changed. Earlier I installed the entire development tools group of packages thinking I might be missing some package. – sthustfo May 04 '20 at 19:50

1 Answers1

4
/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

The configure script needs to be run with --enable-shared for some reason (it is not necessary on Ubuntu). The following worked for me in a docker container with CentOS 8:

./configure --enable-shared
perl -I. Makefile.PL
make
sudo make install
Håkon Hægland
  • 39,012
  • 21
  • 81
  • 174