How to Compile and Build PuTTY on Ubuntu 16.04
This week I needed to compile PuTTY to work on an Ubuntu system running 16.04 (LTS). The instructions are pretty straight-forward and will take you most of the way through compiling something you can use. A problem I ran into is that I kept on running into errors during compilation referencing dlsym, dlopen and dlclose.
Fate was on my side as I was able to work my way through the problem (with a generous dose of google) and comple that actually works.
References
- PuTTY [chiark.greenend.org.uk]
- PuTTY [Github mirror] [github.com/Yasushi]
- Undefined Reference to dlopen, dlclose, dlerror, dlsym [projects.coin-or.org]
- Undefined reference to 'dlsym' and 'dlopen' [stackoverflow.com]
Errors during compilation
When I tried to compile the PuTTY tools on Linux I received some cryptic error messages that weren't particularly helpful for me:
uxgss.o: In function `gss_init':
/home/rion/Repos/other/putty-0.67/unix/../unix/uxgss.c:41: undefined reference to `dlsym'
/home/rion/Repos/other/putty-0.67/unix/../unix/uxgss.c:42: undefined reference to `dlsym'
/home/rion/Repos/other/putty-0.67/unix/../unix/uxgss.c:43: undefined reference to `dlsym'
/home/rion/Repos/other/putty-0.67/unix/../unix/uxgss.c:44: undefined reference to `dlsym'
/home/rion/Repos/other/putty-0.67/unix/../unix/uxgss.c:45: undefined reference to `dlsym'
uxgss.o:/home/rion/Repos/other/putty-0.67/unix/../unix/uxgss.c:46: more undefined references to `dlsym' follow
uxgss.o: In function `ssh_gss_setup':
/home/rion/Repos/other/putty-0.67/unix/../unix/uxgss.c:66: undefined reference to `dlopen'
/home/rion/Repos/other/putty-0.67/unix/../unix/uxgss.c:71: undefined reference to `dlopen'
/home/rion/Repos/other/putty-0.67/unix/../unix/uxgss.c:76: undefined reference to `dlopen'
/home/rion/Repos/other/putty-0.67/unix/../unix/uxgss.c:82: undefined reference to `dlopen'
uxgss.o: In function `ssh_gss_cleanup':
/home/rion/Repos/other/putty-0.67/unix/../unix/uxgss.c:103: undefined reference to `dlclose'
collect2: error: ld returned 1 exit status
Makefile.ux:137: recipe for target 'plink' failed
make: *** [plink] Error 1
Steps to Compile PuTTY
Here are the steps that worked for me to compile PuTTY on Ubuntu:
- Download the 'release source code for Unix' from the PuTTY Download Page
- Extract the .tar.gz file
- Run the ./mkauto.sh script in the root of the directory you extracted PuTTY into
- cd into the unix/ directory
- Run ./configure
- Run make -f Makefile.ux LDFLAGS="-Wl,--no-as-needed,-ldl"
- plink
- pscp
- psftp
- puttygen
The executables work when I run them, so I classify this as a success.