Compiling on MS Windows using Microsoft Visual Studio

Bundle Installation

Bundle for compiling in Visual Studio is available here.


Copy msvc2015 folder to gwyddion source code folder (/trunk/gwyddion folder in svn, simply called gwyddion in the following text).

Generated files

Copy contents of generated-files folder to gwyddion folder.

Python 2.7

Install Python 2.7. Version 2.7.11 does not work. The latest stable version is Python 2.7.9. Python installation packs are in libs-install folder. Install them to C:\libs\Python\Win32 and C:\libs\Python\x64 folders. It is unpossible to link against Python Debug library because python27_d.lib file is missing. It does not help to define MS_NO_COREDLL, Py_NO_ENABLE_SHARED and SWIG_PYTHON_INTERPRETER_NO_DEBUG.

  • copy python27.lib to python27_d.lib
  • in pyconfig.h comment out define Py_DEBUG

python27_d.lib and pyconfig.h are in libs\Python27 folder so you can just copy them to C:\libs\Python27 folder.


Gwyddion depends on external libraries. Set paths to libraries as environment variables. Path must be ended by '\'. Stable versions of these libraries are in libs folder. Example of environment variables setting follows:

CFITSIO_DIR = C:\libs\cfitsio\
GTK_DIR = C:\libs\Gtk\
GTKGLEXT_DIR = C:\libs\GetGLExt\
LIBICONV_DIR = C:\libs\libiconv\
LIBXML_DIR = C:\libs\libxml\
PYTHON_DIR = C:\libs\Python27\
ZLIB_DIR = C:\libs\zlib\

'Build Events'

A part of project build is copying all files needed to run Gwyddion. Specific files are copied from gwyddion folder to $(OutDir) folder (or appropriate subfolder). DLL files are copied from extern library paths defined as environment variables to $(OutDir) folder. Commands are in menu item Project/Properties/Build Events/Post-Build Event.

Solution Generating

Gwyddion is natively compiled on Linux using autotools. Conversion of conditional compilation prescriptions between different platforms is not trivial (conditions, dependencies, variable expansion, different configuration files on Linux/Windows due different library availability). These factors avoid adequate full automatic conversion. is script generating Visual Studio solution and projects. Script must be run in gwyddion folder (see above). Gwyddion must be compiled on Linux before running the script. Linux compilation generates specific .c, .h files and allows script to generate exported function files (.def). All these files are needed for compilation on Windows. They are all sorted to generated-files folder and must be copied to gwyddion folder on Windows. The script results in Visual Studio solution and projects which are generated to msvc2015 folder. All folders generated by script are created in gwyddion folder.

config.h a gwyconfig.h configuration files are natively generated on Linux by autotools. These files correspond to Linux configuration and must be modified to be able to compile in Visual Studio. Prepared Windows friendly configuration files are part of script. These files are copied to generated-files folder during script generating process.


Compile on Linux

On Linux. Run ./ and make in source code folder (usually gwyddion folder). See compilation on Linux/Unix.

Run script to generate solution and to copy out generated files

On Linux. Run in gwyddion folder.

Generated folderContents
msvc2015Gwyddion Solution
msvc2015/generated-files.def, .c, .h files

Copy all files and folders from ./msvc2015/generated-files on Linux machine to ./gwyddion on Windows machine.


On Windows. See the bundle installation section.