GNU TLS FOR WINDOWS -- Instructions for the Windows port of GnuTLS
Copyright (C) 2006, 2007, 2008 Simon Josefsson
See the end for copying conditions.

GnuTLS for Windows

This directory contain files that will build a Windows installer for GnuTLS. The GnuTLS DLL and the normal GnuTLS command-line tools are included. The related helper libraries are also installed: libgpg-error, libgcrypt, and libtasn1. Naturally, full documentation is included, in HTML and PDF formats.

A ZIP file with all the built tools is provided if you want to extract and copy only some files more easily.

A Debian package is provided as well, contributed by Enrico Tassi, if you are building a MinGW project that use GnuTLS on a Debian system and want to reduce manual installation steps.

This work is based on the normal releases of GnuTLS, libtasn1, libgpg-error, and libgcrypt. The source code and any patches are included in installer, and can (optionally) be installed on the target system.


The core GnuTLS library is available under the LGPLv2 license. Some parts of the package is available under the GPL license, such as the libgnutls-extra library, and the command line tools.

The build infrastructure to produce the GnuTLS for Windows builds are released under GPL version 2 or later.


If you find this work useful to you, please contribute back! Contributions will help me develop and make future releases of GnuTLS.

If you need commercial grade support, please contact me directly, since I'm available as a consultant.


Transfer the "gnutls-*.exe" file to a Windows box and run it. After the installation has finished, you should be able to run the "gnutls-cli" tools from a CMD.EXE prompt.


Build Environment

I'm using Debian x86 testing with the MinGW cross-compiler and the NSIS installer. You will need Wine to run the self tests for "make check".

# apt-get install make mingw32 nsis wine

Build Instructions

First checkout the files in this directory as follows:

cvs -z3 co gnutls4win

You may browse the files in CVS.

Typing "make" should build libgpg-error, libgcrypt, libtasn1 and gnutls, and then build the binary installer using NSIS and a ZIP file with all the files.

If this fails, start by trying to get libtasn1 to build. Type "make libtasn1". Then continue with the other packages. After that, the only remaining part is the installer.

Using the GnuTLS DLL from your Cygwin or MinGW program

Link with the libgnutls.dll.a file. If you are using MinGW instead of Cygwin, replace /cygdrive/c with /c below.

$ cat > foo.c
#include <gnutls/gnutls.h>
int main (void)
  printf ("foo %s\n", gnutls_check_version (NULL));
$ gcc -o foo foo.c -I/cygdrive/c/Program\ Files/GnuTLS/include /cygdrive/c/Program\ Files/GnuTLS/lib/libgnutls.dll.a

Then run the program.

$ ./foo
foo 1.6.0

Using the GnuTLS DLL from your Visual Studio program

The first step is create an import library. Start a MSVS Command Prompt, and go to the GnuTLS installation directory.

C:\Program Files\GnuTLS\bin>lib /def:libgnutls-26.def

This will create a libgnutls-26.lib that can be used as a import library for Visual Studio projects.

Build a sample program to test it as follows:

C:\Program Files\GnuTLS\bin>cl foo.c -I../include -Dssize_t=long libgnutls-26.lib
C:\Program Files\GnuTLS\bin>foo
foo 1.6.0
C:\Program Files\GnuTLS\bin>

These steps are not fully polished yet, but appear to work.

Known problems

  1. Some of the command line tools (e.g., gnutls-cli) uses select() to check whether there is data to be read from stdin or from the network. The select function doesn't work with file descriptors under Windows, so this currently does not work. I'm working on solving this. Update! This was improved by 1.5.1, but still not perfect. Reports on that are solicited.

  2. Initializing libgcrypt takes a long time on some systems, there has been reports that it can take around 10 seconds. There is a patch for libgcrypt to solve this, and there are non-official libgcrypt DLL's that can be used as a drop-in. See and Note that it is not clear whether the patch is the right solution or not.


Ask on for general problems, and discuss any suggested modifications If you wish to contact me directly, try

Copying and distribution of this file, with or without modification,
are permitted in any medium without royalty provided the copyright
notice and this notice are preserved.

$Id: README.html,v 1.8 2008/05/26 11:27:05 jas Exp $