Table Of Contents

Previous topic


Next topic


This Page


Pre-built binaries

On a windows platform, you are likely to run into more problems than on linux when building from source. Therefore, we will try to provide built versions for some platforms. If your platform is supported, you can just run

pip install cern-cpymad

from your terminal and that’s it. If this fails, you will need to build from source. The following guide assumes that you use MinGW as compiler suite.

Install dependencies

I recommend to use Python(x,y). This is a python distribution which includes all Dependencies except for CMake. Make sure Cython and MinGW are marked for installation.


If you want to use another python installation things will get more complicated. I recommend the following resources:

Now install CMake. In the Install options dialog choose to Add CMake to the system PATH for all/current user according to your liking.


You can also select Do not add CMake to the system PATH. In this case you will need to manually extend your PATH later on in the terminal:

set PATH=%PATH%;C:\Program Files (x86)\CMake\bin

Build libmadx

Download and extract the MAD-X source from SVN.


If the latest release contains bugs that have been fixed in the meantime you may want to download the latest revision from SVN. Be aware though, that the latest revision is not at all guaranteed to be stable or even buildable.


You might need multiple extraction steps until you get a folder containing the file CMakeLists.txt as well as several other files and subdirectories.

I recommend to build MAD-X as a static library as described below. This way, you won’t need to carry any .dll files around and you won’t run into version problems when having a multiple MAD-X library builds around.

Python(x,y) provides an Open enhanced console here context menu item when right-clicking on a folder in the explorer. Open the madX folder with it and run the commands:

mkdir build
cd build
make install

This will install the headers, binaries and library files to the madX/install subfolder.


You can also use the regular console cmd.exe. In this case extend the PATH environment variable with your python and MinGW installation:

set PATH=%PATH%;C:\MinGW32-xy\bin
set PATH=%PATH%;C:\Python27
set PATH=%PATH%;C:\Python27\Scripts


If executing CMake from the GUI, you have to disable the BUILD_SHARED_LIBS option, if present. Afterwards reconfigure and regenerate.

Build CPyMAD

Download the CPyMad source. Then go to the pymad folder and build as follows:

python build --compiler=mingw32 --madxdir=<madx-install-path>
python install

Substitute <madx-install-path> with the madX\install subfolder as specified by CMAKE_INSTALL_PREFIX before.