msys2 or MSVC.
There are two ways to compile
igraph on Windows. You can either build from the released source code, or you can
build from the
git repository. Compiling from the released source code is sometimes easier, as it
already provides a project file that can be used to compile with Microsoft Visual C++ (MSVC). Of course,
compilation from the released source code is limited to released versions, while compilation from the
git repository allows you to also compile development versions. Compilation can always be done using
MinGW, but if you want to use
igraph with Python (e.g. as an external library for
python-igraph) you have to use MSVC. Each Python version requires a specific version of MSVC, please
see the Python website for more
details. Preparing a project file to compile with MSVC is again done using MinGW (
In summary, there are two routes to compiling
More detailed instructions are provided below.
The instructions below assume that you want to compile for a 64-bit target.
msys2, first make sure that it is up-to-date. You can do so by opening an
bash terminal and run:
You may be requested to close and restart the
bash terminal at several points.
Please repeat executing
pacman -Syuu until it says there are no longer any packages to update. More
details regarding the installation of
msys2 are available from their Wiki.
igraph requires the installation of a number of packages, namely:
mingw-w64-x86_64-toolchain also includes the optional Gnu Multiple Precision package
mingw-w64-x86_64-gmp. This enables extended
You can install these packages by running the following command in an
pacman -S autoconf automake bison flex libtool make mingw-w64-x86_64-toolchain mingw-w64-x86_64-libxml2 mingw-w64-x86_64-gmp git zip
Once everything is installed you need to open the
msys2 "MinGW 64-bit" terminal
You can either download the source code archive of the
latest release or clone the
git repository using
git clone https://github.com/igraph/igraph.git. When cloning from GitHub, please ensure that you run
git config --global core.autocrlf false before cloning the repository. Otherwise, you might run into
problems with line endings.
After extracting the source code, open a
bash terminal (from either
cygwin) and change to the directory in which the source code is located. When using
msys2, use the "MSYS2 MinGW 64-bit" terminal, and not the "MSYS2 MSYS" one.
If you have cloned the source code from the
git repository, you must first create the build scripts
Compilation is done with the usual steps of
If you have multiple cores, for example 4, you can run
make -j4 to speed up the compilation
You can install the library by running
make install. If you prefer to install it in a specific
location, you can specify
./configure, in which case the library
will be installed into the
include subdirectories of
[DIRECTORY]. If you just need the built
dll file, this is located in
You may optionally run the test suite using
make check. Before doing this, ensure that the directory
libigraph-0.dll is in the
PATH. This can be achieved for example using the
export PATH=$PATH:`realpath src/.libs`
If you intend to compile with Microsoft Visual C++, you will need a project file for Microsoft Visual C++. This can be done by following the above steps, except for the last step, and then creating the MSVC project file using
./configure make msvc
The necessary source code for compilation with MSVC is then contained in the newly created
igraph-[VERSION]-msvc directory, where
[VERSION] refers to the version that you are
Compilation using MSVC is primarily necessary for use with Python, in particular for
Note that different versions of Python require different versions of MSVC. See the Python website for more details.
The provided project file is still provided in an older MSVC format. To use it with more recent versions of MSVC,
you will have to upgrade the project file. Note that this can only be done if you have the the full Microsoft
Visual Studio installed. You can install the Community edition, which is freely available. The Microsoft Visual C++ Build Tools that
are available do not allow you to upgrade the project file, which is necessary to be able to compile
Compilation can be done in two ways. The easiest way for most users is to open the project
solution file (
igraph.sln) in the Visual Studio IDE. It will ask you to convert it to the current
format, and you should be able to compile it, once it is converted.
Alternatively, you can compile via the command line. In that case, open the "Developer Command Prompt", and depending on your version of MSVC, you should do the following
vcbuild.exe /upgrade vcbuild.exe igraph.vcproj "Release|x64"
VCUpgrade.exe /overwrite ig.vcproj msbuild.exe igraph.vcxproj
devenv /upgrade igraph.vcproj msbuild.exe igraph.vcxproj
By default, compilation on Windows targets a static library (
.lib), which is necessary for the
python-igraph. To import the static library, you have to make sure to specify
#define IGRAPH_STATIC 1
before you include
Alternatively, you can reconfigure the MSVC project to compile a dynamic library (
which case the
IGRAPH_STATIC definition should not be included.
A small test project is included in the
igraphtest subdirectory of the