Compiling PuTTY for Windows

Because of one awesome bug inflicts eye-cancer when using Consolas font and deactivated “Bold text is a different colour”, I had to recompile PuTTY by hand (more like, by gcc). I initially tried to compile the PuTTYTray one but apparently they successfully mixed C and C++ code and completely broke the build procedure using mingw. Or I missed something obvious.

Anyway, I went back to vanilla PuTTY. As it turns out, compiling using latest mingw’s gcc isn’t a good idea since it removed -mno-cygwin option and therefore broken unless you do some magic edit. Thanks to that, I stopped bothering trying to compile it under Windows and used mingw-gcc for Linux (which is able to produce Windows binary). Here be the steps from beginning. Tested on Debian 6.

apt-get install mingw32 subversion perl
svn co svn:// putty
cd putty
cd windows
make VER="-DSNAPSHOT=$(date '+%Y-%m-%d') -DSVN_REV='$(svnversion)' -DMODIFIED" TOOLPATH=i586-mingw32msvc- -f Makefile.cyg putty.exe

Patch is done before make (duh) and the diff can be found here. If you’re lazy (like me) you can just download the build at my server (link at bottom). Should be virus-free but I guess you can notify me if you encounter one. Built everyday until it breaks.

  • exe: the program
  • sha512: hash of the program
  • zip: both program and its checksum

[ exe | sha512 | zip ]

7 thoughts on “Compiling PuTTY for Windows

  1. I had to change -DSVN_REV=$(svnversion) to -DSVN_REV=”$(svnversion)” since it was coming out with “Unversioned directory” (note the whitespace) which was causing windres to break. Thanks for your post!

  2. Hi!
    I get this error on make:
    i586-mingw32msvc-gcc -mno-cygwin -Wall -O2 -D_WINDOWS -DDEBUG -DWIN32S_COMPAT -D_NO_OLDNAMES -DNO_MULTIMON -DNO_HTMLHELP -DNO_SECUREZEROMEMORY -I.././ -I../charset/ -I../windows/ -I../unix/ -I../macosx/ -D_WIN32_IE=0x0500 -DWINVER=0x0500 -D_WIN32_WINDOWS=0x0410 -D_WIN32_WINNT=0x0500 -c ../windows/winshare.c
    In file included from ../windows/winshare.c:15:
    .././ssh.h:159: warning: type qualifiers ignored on function return type
    .././ssh.h:162: warning: type qualifiers ignored on function return type
    ../windows/winshare.c: In function ‘obfuscate_name’:
    ../windows/winshare.c:57: error: ‘CRYPTPROTECTMEMORY_BLOCK_SIZE’ undeclared (first use in this function)
    ../windows/winshare.c:57: error: (Each undeclared identifier is reported only once
    ../windows/winshare.c:57: error: for each function it appears in.)
    ../windows/winshare.c:85: error: ‘CRYPTPROTECTMEMORY_CROSS_PROCESS’ undeclared (first use in this function)
    make: *** [winshare.o] Error 1

    I installed mingw32, are there any other packages needed…?

    • You can try adding XFLAGS=-DCOVERITY in the make command but you might be better asking the dev directly.

  3. for mingw-w64 toolchain I use forllowing

    if [ -z “$TGZ” ]
    echo USAGE: $0 ‘/path/to/putty.tar.gz’

    pack () {
    local suffix=$1
    for exe in `ls -1 *.exe`
    dest=`echo $exe|cut -f1 -d.`-$suffix.exe
    mv $exe $dest
    zip -9 putty-suite-$ *-$suffix.exe
    mv putty-suite-$ ../../

    SRC_DIR=`echo $TGZ|cut -f1 -d.`

    tar -xf $TGZ
    cd $SRC_DIR

    cd windows
    sed -ri ‘s/-mno-cygwin//g’ Makefile.cyg

    now=`date +%Y-%m-%d`

    make VER=”-DSNAPSHOT=’$now’ -DSVN_REV=’$SRC_DIR’ -DMODIFIED” TOOLPATH=x86_64-w64-mingw32- -f Makefile.cyg all
    pack x64

    make -f Makefile.cyg clean
    make VER=”-DSNAPSHOT=’$now’ -DSVN_REV=’$SRC_DIR’ -DMODIFIED” TOOLPATH=i686-w64-mingw32- -f Makefile.cyg all
    pack x32

  4. Hello, compiling with XFLAGS=-DCOVERITY works for me, too. Thanks!
    I want to disable user’s ability to right-click on the top of the PuTTY boarder and get a context-menu but I could not figure out which function to modify. Could you help?

Leave a Reply

Your email address will not be published. Required fields are marked *