CGAL Installation Guide:

MinGW|MSYS case.

Posted by Oussama Ennafii on December 27, 2016


 The Computational Geometry Algorithms Library (a.k.a. CGAL) is a C++ Library providing efficient algorithms for geometric computations. You can have more detailed informations at its official Website.

 This guide was tested for release 4.9 on a windows 10 ( but should work also for Windows 7 , 8 and 8.1). I tried to apply the instructions available already on the internet, but it did not work for me as I wanted an installation for my project like the one you can get on Unix like operating systems. In fact, You can, for instance, choose to ignore GMP and MPFR dependencies if you want to build CGAL on Visual Studio. Luckily, There is Minimalist GNU for Windows (MinGW). There is also Cygwin, but I was advised not to use it; which makes sense since you can get Linux on your Windows 10 now!

Dependencies needed for this Guide:

CMake (required)
git (optional)
MinGW/MSYS (required)
Gmp, MPFR (required)
zlib (optional)
Boost (required)

 In what follows, I will go through these one by one.


 You can download the official installer for the latest release from their website. The installer should be self explanatory. If you prefer to install cmake from command prompt you can type this command:

Invoke-WebRequest -OutFile "C:\Path\to\cmake.msi"

msiexec /i "C:\Path\to\cmake.msi" /passive /quiet /norestart /log "C:\Path\to\cmake_installation.log"

 /passive parameter is used to get the status bar and is not essential. You can have a look at the log to check the installation process.

 Don’t forget to add CMake binaries to your %PATH%.


 Git is a distributed versioning manager. It has become the standard recently in the program development community. It is easy to migrate, if need be, from SVN and Mercurial to Git. Platforms, like GitHub and GitLab, where you can navigate through various projects, make good ambassadors for Git.

 You can get the official binary release at their download page. Afterwhat, run the setup executable and choose the components you want to install. You can choose to run git from Git Bash and/or Command Prompt. In the third step, you choose how to deal with line endings: Either you checkout CRLF and commit LF, checkout as-is and commit LF or checkout and commit as-is. You can change that later for your projects using git attributes. If you have chosen to install Git Bash you have to choose in the forth step the default terminal. You have some other extra configuration choices to take afterwards and you are ready to install.

 You can also launch the setup binary file unattended as follows:

Invoke-WebRequest -OutFile "C:\Path\to\git-setup.exe"

"C:\Path\to\git-setup.exe" /SILENT /SMS /SetupType=default /COMPONENTS=ext,ext\shellhere,ext\guihere,assoc,assoc_h /LOG="C:\Path\to\git-installation.log"

 For more details, you can take a look at this setup file.


 MinGW stands for Minimalist GNU for Windows. It provides minimal binaries to port GNU specific projects to Windows. MSYS, on the other hand, stands for minimal system. It bundles many utilities used in Unix World and not present in Windows : I can site bash, sed, less and grep as examples. MinGW has one advantage over Cygwin: the later does need the external library cygwin1.dll.

 The easiest way to install MinGW is to get your hands on the setup executable. It is self explanatory. You can continue to use the installation manager graphical interface to choose the components you want or you can use the command prompt like your favorite Linux package manager. For the latest option, download the latest release of mingw-get and you can bootstrap all components you are looking for:

Invoke-WebRequest -OutFile "C:\Path\to\"

7z x "C:\Path\to\" -o "C:\MinGW"

 You can look for further details in the official website.

 For starters, you can install the following:

mingw-get install gcc g++ mingw32-make libtool gdb msys-bash

 You need to add MinGW and/or MSYS - C:\MinGW\binand C:\MinGW\msys\1.0\bin for instance - in your %PATH%. It is probable that you will have a problem while calling bash.exe in the command prompt, as it calls the shell installed with Git Setup. To solve this problem, you could call this PowerShell function (Courtesy of Marouane Fazouane):

function Import-Msys {
        [string] $MsysPath = "C:\MinGW\msys\1.0\bin",
        [string] $MingwPath = "C:\MinGW\bin"
        $local:GitPaths = ""
        foreach($item in ($env:Path.Split(";") | Group-Object { $_.Contains("Git") })){
            if($item.Name -eq $true) {
                $local:GitPaths = $item.Group -join ";"
            else {
                $env:Path = $item.Group -join ";"
        foreach($item in @( $MsysPath, $MingwPath, $local:GitPaths )){
            if(-Not ($env:Path.Split(";") -contains $item)){
                $env:Path = "$env:Path;$item"


  • If you need to run a ./configure script, you need to do so on msys-bash.
  • If you are using CMake, you have two choices:
    • -G"MinGW Makefiles": you should not have MSYS (or Git) shell in your %PATH%,
    • -G"MSYS Makefiles": you build your project on msys-bash

GMP, MPFR and zlib

 CGAL does not require anymore GMP and MPFR. You can check them out using CMake. However, if you insist to have them, it is easy to do so:

mingw-get install mingw32-gmp mingw32-mpfr

 CGAL has four main targets: CGAL, CGAL_Core, CGAL_ImageIO and CGAL_QT5. Unfortunately, QT5 is not recommended for MinGW 32bits. You can try to build QT5 from scratch but it is fastidious.

 CGAL_ImageIO , on the other hand, needs zlib to build. You need to get the development package:

mingw-get install libz-dev


 Two scenarios present themselves: Build everything using MinGW or MSYS. It depends really on your needs. If you have other dependencies for your project that needs a ./configurestep, it is strongly recommended to use MSYS. To build boost, you will have to follow the same steps. The only difference, among other things, will be the installation prefix ( MinGW -> C:\Boost and MSYS -> C:\Path\to\msys\usr\[include|lib]) and cmake will not be able to find boost if you choose the wrong Makefiles type. Once you decide your platform, you should get the release you want from the official website and save it to your machine:

cd "C:\Path\to\Boost\tools\build"
.\b2 install -j4 --build-type=minimal --toolset=gcc
cd "..\.."
.\b2 install -j4 --build-type=minimal --toolset=gcc

You can of course, change the prefix --prefix=, but the default should be fine.

CGAL installation

 You should be all set now to build CGAL:

cd "C:\Path\to\CGAL"
mkdir build
cd build

cmake -G"[MSYS|MinGW] MakeFiles" ..
make -j4 all
make -j4 install
make install_FindCGAL


  • It is mindless to say that you should run this while having administrative rights;
  • If you don’t take the last step into account, you will have to precise CGAL_DIR (the directory containing CGALconfig.cmake) to CMake each time you want to use CGAL;
  • By this notation [<x>|<y>], I mean you choose either <x> or <y>.