How-To's‎ > ‎Simulation-Modeling‎ > ‎Mantid‎ > ‎

Building in Windows

These are some remarks for building Mantid in Windows from source. I followed the process detailed in the  Building Mantid with Visual Studio Express page with some modifications.

  1. Download Visual Studio Express 2012. You will have to register it the first time you open the application. I tried building with VSE 2010 and 2013 with no luck
  2. Download and install the Windows installer for Cmake 2.8.X Mind you, Version 2.6.X will not work with VSE 2012.
  3. Download and install Git Bash. Then see the instructions on checking out mantid here: Checking_out_the_Mantid_Code. I checked out to c:\mantidproject\mantid with the git bash console and using the HTTPS protocol (git clone https://YOURGITHUBUSERNAME@github.com/mantidproject/mantid.git).
  4. Use cmake-gui to create an out-of-source build. See Building_with_CMake for instructions. I selected directory C:\mantidproject\mantid\Code\release as my out-of-source build. Select the "Visual Studio 11 Win64" generator (strange, but the generator corresponding to VSE 2012 is called "Visual Studio 11", and the generator corresponding to the latest VSE 2013 is called "Visual Studio 12"). If something gets iffy, you can delete the cache and start afresh.
  5. Start VSE 2012 (and register it if this is the first time you open it). Open the project in Visual Studio C++ 2012. If you are going to test python algorithms or fitting functions, then you must do a release build. The default is a debug build. To change this setting in, for instance, the ALL_BUILD project, then right-clik in ALL_BUILD, then Properties. In the pop-up, click on the Configuration Manager (upper-right corner) and change the Active build to release.
  6. Build ALL_BUILD. By default, the  build will use multiple cores to speed up the process.
  7. Update the PATH system variable to include C:\mantidproject\mantid\Code\Third_Party\lib\win64 and C:\mantidproject\mantid\Code\Third_Party\lib\win64\python.
  8. The MantidPlot executable is located under C:\mantidproject\mantid\Code\bin\Release.


Running Unit Tests

To learn guidelines about unit testing in Mantid, go to the Running the units tests page. (NOTE: If you want to run only python unit tests, then there is no need to build the any test suite)

To run a single test, go to your out-of-source directory (in my case, C:\mantidproject\mantid\Code\release) and create there a link to the ctest executable. In my case, it is located under "C:\Program Files (86x)\Cmake\bin\ctest.exe". I want to run unit-test StretchedExpFFTTest, thus I type:

ctest.exe.lnk -C Release -R StretchedExpFFTTest

Debugging a python unit test

In this example we want to debug unit test  C:\mantidproject\mantid\Code\  . We do:

  1. Create or append to the PYTHONPATH system variable: PYTHONPATH=%PYTHONPATH%;C:\mantidproject\mantid\Code\release\bin\Release
  2. Open a Windows command line as administrator and go to directory  C:\mantidproject\mantid\Code\.
  3. Edit file and insert from pdb import set_trace and set the trace wherever you want to start the debugging. Learn more about the pdb debugger if neccessary.
  4. run python StretchedExpFFTTest.py to start the debugging session.