3

When I make Perl 5.10.1 I get some errors, I found some related threads that stated:

The error messages are from the linker, not from the compiler. You should get away by placing a -lm at the end of all compilation lines.

My Question is where are the compilation lines that I need to add -lm to ?

miniperlmain.o opmini.o perlmini.o 
pp.o: In function `Perl_pp_pow':
pp.c:(.text+0x2daf): undefined reference to `pow'
pp.o: In function `Perl_pp_modulo':
pp.c:(.text+0x39fc): undefined reference to `floor'
pp.c:(.text+0x3a28): undefined reference to `floor'
pp.c:(.text+0x3a51): undefined reference to `fmod'
pp.o: In function `Perl_pp_atan2':
pp.c:(.text+0x89c5): undefined reference to `atan2'
pp.o: In function `Perl_pp_sin':
pp.c:(.text+0x8b62): undefined reference to `sin'
pp.o: In function `Perl_pp_int':
pp.c:(.text+0x9021): undefined reference to `floor'
pp.c:(.text+0x9091): undefined reference to `ceil'
pp.o:(.rodata+0x120): undefined reference to `cos'
pp.o:(.rodata+0x128): undefined reference to `sin'
pp.o:(.rodata+0x130): undefined reference to `sin'
pp.o:(.rodata+0x138): undefined reference to `exp'
pp.o:(.rodata+0x140): undefined reference to `log'
pp.o:(.rodata+0x148): undefined reference to `sqrt'
pp_pack.o: In function `S_pack_rec':
pp_pack.c:(.text+0x72b3): undefined reference to `floor'
pp_pack.c:(.text+0x72d6): undefined reference to `floor'
pp_pack.c:(.text+0x7303): undefined reference to `floor'
collect2: error: ld returned 1 exit status
make: *** [miniperl] Error 1
techraf
  • 4,163
  • 8
  • 27
  • 44
rreeves
  • 171
  • 2
  • 11

1 Answers1

2

I encountered the same problem when I was building Perl 5.8 included in the SPEC benchmark suite on a Lemote 8089 laptop with a MIPS processor running GNewSense 4. Perl failed to build because it could not find the Math Library when it was running test lib/ExtUtils/t/Embed during the build process. The error messge looks almost the same as yours.

The solution is to pass in linker flags -lm by saying

PERLFLAGS="-A libs=-lm -A libs=-ldl -A libs=-lc -A ldflags=-lm -A cflags=-lm -A ccflags=-lm -Dnoextensions=IPC/SysV -Dperl" \
CONFIGFLAGS="--build=mipsel-linux-gnu" ./buildtools

The trick here is the linker flag is called Lowercase ldflags rather than LDFLAGS as found in many other software packages. Also, adding a flag to ldflags is done by using the -A (probably means "append") directive in PERLFLAGS.

(It is the second flag ldflags=-lm that fixed the problem here, but may be both libs and ldflags are needed for the whole Perl to build.)

  • Can you specify how to apply this solution when trying to install perl? `PERLFLAGS` does not exist anywhere in the makefile. https://askubuntu.com/questions/1300500/install-perl-5-10-1-on-ubuntu-18-04 – CoderGuy123 Dec 16 '20 at 09:45