Saturday, February 26, 2022

[SOLVED] unable to compile PuTTY 0.76 on Ubuntu 20.04

Issue

I'm trying to compile PuTTY 0.76 on Ubuntu 20.04 using the directions from https://7thzero.com/blog/how-to-compile-build-putty-ubuntu-16 and am having some difficulty.

My steps:

It fails on the last command with this error:

cc  -O2 -Wall -std=gnu99 -Wvla -g -I.././ -I../charset/ -I../windows/ -I../unix/ -D _FILE_OFFSET_BITS=64  -c ../sshpubk.c
cc -o cgtest cgtest.o conf.o console.o ecc.o import.o marshal.o \
        memory.o millerrabin.o misc.o mpint.o mpunsafe.o notiming.o \
        pockle.o primecandidate.o smallprimes.o sshaes.o sshargon2.o \
        sshauxcrypt.o sshbcrypt.o sshblake2.o sshblowf.o sshdes.o \
        sshdss.o sshdssg.o sshecc.o sshecdsag.o sshhmac.o sshmd5.o \
        sshprime.o sshprng.o sshpubk.o sshrand.o sshrsa.o sshrsag.o \
        sshsh256.o sshsh512.o sshsha.o sshsha3.o stripctrl.o time.o \
        tree234.o utils.o uxcons.o uxgen.o uxmisc.o uxnogtk.o \
        uxnoise.o uxpoll.o uxstore.o uxutils.o version.o wcwidth.o \
        -Wl,--no-as-needed,-ldl
/usr/bin/ld: sshprime.o: in function `provableprime_add_progress_phase':
/home/wiggie/putty/putty-0.76/unix/../sshprime.c:255: undefined reference to `pow'
/usr/bin/ld: sshprime.o: in function `estimate_modexp_cost':
/home/wiggie/putty/putty-0.76/unix/../sshprime.c:761: undefined reference to `pow'
/usr/bin/ld: sshprime.o: in function `provableprime_generate_inner':
/home/wiggie/putty/putty-0.76/unix/../sshprime.c:485: undefined reference to `pow'
/usr/bin/ld: sshprime.o: in function `estimate_modexp_cost':
/home/wiggie/putty/putty-0.76/unix/../sshprime.c:761: undefined reference to `pow'
collect2: error: ld returned 1 exit status
make: *** [Makefile.ux:127: cgtest] Error 1

Any ideas?

(I'm aware that I could prob just install it using apt-get but I want to make some changes to it and apt-get isn't gonna help me do that)


Solution

pow() is a function from the maths library, libm. Your LDFLAGS needs to include "-lm". See https://man7.org/linux/man-pages/man3/pow.3.html



Answered By - James McPherson
Answer Checked By - Timothy Miller (WPSolving Admin)