1.3.3.1. Installing LithoGraphX from Source on Microsoft Windows

There are two ways of compiling for Windows: the recommended way using MinGW64 or using Visual Studio.

1.3.3.1.1. Compilation with MinGW64 – The Easy Way

The easier way to compile with MinGW64 is to install it via MSys2: http://sourceforge.net/projects/msys2/

Here is a step by step method to install all the libraries you need for LithoGraphX.

  1. (Cuda version only) Install Visual Studio 2013, for example the community edition which is available for free on http://www.visualstudio.com. From this version, you only need the C++ component.

  2. (Cuda version only) Install the CUDA drivers. Note: These must be installed after Visual Studio, so CUDA find it and install all the necessary components.

  3. Install MSys2 using the graphical installer

  4. Open the MSys2 Win64 shell using the shortcut installed in the start menu.

  5. Upgrade MSys2 using pacman, the package manager of MSys2:

    $ pacman -Su
    
  6. Install the packages we need for LithoGraphX:

    $ pacman -S mingw-w64-x86_64-libtiff mingw-w64-x86_64-qt5 mingw-w64-x86_64-python2-pyqt5 mingw-w64-x86_64-eigen3 mingw-w64-x86_64-cmake doxygen
    
  7. (Optional). Install VTK:

    $ pacman -S mingw-w64-x86_64-vtk mingw-w64-x86_64-opencv
    

    We also need to install OpenCV as it is a dependence of VTK. However, as far as the version 20150512 of MSys2 is concerned, OpenCV is not installed automatically with VTK.

  8. (Optional). Install ITK. Sadly, the version of ITK that comes with MSys2 doesn’t include the auto-seeded morphological watershed, central in so many protocols of LithoGraphX. So we need to compile it ourselve:

    1. Download ITK from http://www.itk.org

    2. Prepare your directory structure. For simplicity, I will assume everything linked to ITK will be in the same folder. This folder will contain three sub-folder:

      ITK_Source

      Contains the source code of ITK

      ITK_Build

      Will contain the build files of ITK

      ITK

      Will contain the installed version of ITK

    3. Make sure the three directories exist, and ITK_Source contains the source code.

    4. Launch a MSys2 Win64 shell, using the shortcut in the start menu.

    5. Go to the ITK folder. Careful: MSys2 has an odd syntax. For example, if your folder is C:\Users\Me\ITK, then you need to type:

      $ cd /C/Users/Me/ITK
      
    6. Configure ITK:

      $ cd ITK_Build
      $ cmake -G "MinGW Makefiles" -DCMAKE_CXX_FLAGS="-std=c++11" -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTING=OFF -DBUILD_EXAMPLES=OFF -DBUILD_SHARED_LIBS=ON -DModule_ITKReview=ON -DCMAKE_INSTALL_PREFIX=../ITK ../ITK_Source
      
    7. Then, compile and install ITK:

      $ make -j4 install
      
  9. (Optional). Install the GNU Scientific Library:

    $ pacman -S -s mingw-w64-x86_64-gsl
    
  10. (NoCuda version only) Download and extract the thrust library https://thrust.github.io. As this library only contains header files, there is nothing to compile. Simply mark down where it is installed.

  11. (Cuda version only) Create batch scripts to have both MinGW64 and Visual Studio compilers available. For the default installation of Visual Studio and MinGW64, the script should contain:

    call "C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\vcvarsall.bat" amd64
    @echo Visual Studio installed in current shell
    @set MINGW64=C:\msys64\mingw64
    @set PATH=%MINGW64%\bin;%PATH%
    @echo MINGW64 installed in current shell
    

    You might also want to create a shortcut to start the shell. Right-click somewhere (for example the desktop) and select New->Shortcut. In the dialog box that appear, for location type:

    %comspec% /k ""C:\Path\to\script.bat""
    

    For the following, use the shortcut to open a terminal, and go to the LithoGraphX source tree:

    $ cd C:\Users\Me\LithoGraphX
    
  12. (NoCuda version only). Open an msys Win64 shell from the start menu, and go to the LithoGraphX source tree:

    $ cd /C/Users/Me/LithoGraphX
    
  13. Create a Build folder in the LithoGraphX source tree:

    $ mkdir Build
    $ cd Build
    
  14. Configure LithoGraphX:

    $ cmake-gui ..
    
    1. (Cuda version) Select MinGW Makefiles

    2. (NoCuda version) Select MSys Makefiles

    3. On the right of the search box, check the boxes Grouped and Advanced.

    4. Press the Configure button and check for errors until there are none left. Typically, you will need to inform the following variables:

      PYTHON_EXECUTABLE

      CMake will find the program python.exe, but really you want python2.exe in the same folder

      PYTHON_LIBRARY

      If you already have python installed, CMake may find it instead of the python for MinGW64. If you left the default installation folder of MSys2, the correct path for the library is C:/msys64/mingw64/lib/libpython2.7.dll.a

      SIP_EXECUTABLE

      This is the path to the sip.exe program. It should be at C:/msys64/mingw64/bin/sip.exe.

      SIP_PYQT5_CORE_PATH

      This is the path to the Core module of PyQt5. This should be C:/msys64/mingw64/share/sip/Py2-Qt5/QtCore

      SIP_PYQT5_PATH

      This is the path to all the modules of PyQt5. This should be: C:/msys64/mingw64/share/sip/Py2-Qt5

      THRUST_BACKEND_CUDA / THRUST_BACKEND_OMP

      Check one or the other depending on whether you want to compile with CUDA or not. If not, you can delete the whole CUDA group.

      CMAKE_BUILD_TYPE

      Set this one to Release to compile with all the optimizations.

      CMAKE_INSTALL_PREFIX

      If you don’t want to install LithoGraphX into the Program Files folder, change the value. Note that to install in Program Files, you need to set the proper permissions, unless you use the installer.

      BUILD_ITK

      If you have build ITK, check this box. The last build of ITK should be found automatically.

      BUILD_VTK

      If you have installed VTK, check this box. Again, CMake should find where it is automatically.

    5. When you are done configuring, press the Generate button. If there is no error, you are done with configuring LithoGraphX.

  15. Now, you need to compile LithoGraphX. If you use the MSys command line, you need to type:

    $ make -j8
    

    Otherwise, you need to type:

    $ mingw32-make
    
  16. Once compiled, you can either directly install LithoGraphX, or create a package you can re-distribute. We recommend the creation of a package. For this, from the command line, type:

    $ cpack -G NSIS64
    

1.3.3.1.2. Compilation with MinGW64 – The Hard Way

This is another way to get MinGW64 with all the libraries. It avoids compiling MinGW64 and Qt, but almost all the other dependencies are compiled.

Because CUDA requires Visual C++ under windows, and because we are using MinGW64 for the rest of the compilation, you have to be careful when installing your development environment. Here, I will describe how to install it for CUDA 7.0:

  1. Install Visual Studio 2013, for example the community edition which is available for free on http://www.visualstudio.com. From this version, you only need the C++ component.

  2. Install the CUDA drivers. Note: These must be installed after Visual Studio, so CUDA find it and install all the necessary components.

  3. Install python. We highly recommend using Anaconda. Once installed, you will need to install the libpython conda package.

  4. Download the source code of SIP and PyQt5 from http://www.riverbankcomputing.com

  5. Download the version of Qt5 corresponding to the version of PyQt5 you downloaded from http://sourceforge.net/projects/qt64ng Note: This version of Qt5 also contains python 2.7. However, to make it work you need to go into mingw64\opt\bin and copy the file libpython2.7.dll to mingw64\libs\python27.dll (the folder doesn’t exist)

  6. Download MSys from the MinGW64 website here: http://sourceforge.net/projects/mingw-w64/files/External%20binary%20packages%20%28Win64%20hosted%29/

  7. To make your life simpler, create two scripts that will add the path to MinGW64 to your PATH environment variable: one for the command shell, and one for UNIX shell. Assuming you installed MinGW64 in C:\MinGW64, the first script should be called mingw64.bat and have for content:

    @set MINGW64=C:\MinGW64
    @set PATH=%MINGW64%\bin;%MINGW64%\opt\bin;%MINGW64%\opt\libs;%PATH%
    

    The second script should be called mingw64.sh and have for content:

    export PATH=/c/MinGW64/bin:$PATH
    

    This way, when you open a terminal, if this is a windows command, you can type:

    $ call mingw64.bat
    

    and have MinGW64 available, or for MSys shell:

    $ source mingw64.sh
    
  8. Compilation of SIP
    1. Start a windows command and setup your environment variables for MinGW64:

      $ call mingw64.bat
      
    2. Configure sip:

      $ python configure.py -p win32-g++
      
    3. Compile and install:

      $ mingw32-make
      $ mingw32-make install
      
    4. Copy the file sip.exe in %MINGW64%\opt to %MINGW64%\opt\bin

# Compilation of PyQt5
  1. Start a windows command and setup your environment variables for MinGW64 (you can re-use the one open for SIP)

  2. Configure PyQt5:

    $ python configure.py --spec=win32-g++
    
  3. Compile and install:

    $ mingw32-make
    $ mingw32-make install
    
  4. Copy the files in %MINGW64%\opt to %MINGW64%\opt\bin

  1. Download the source code of libtiff5 from the GNUWin32 project: http://gnuwin32.sourceforge.net/packages/tiff.htm

    1. Launch the MSys shell
    2. Setup the environment variables for MinGW64
    3. Create a build directory and change to it (optional)
    4. Run the configure script, specifying a prefix
    5. Compile and install
  2. (Optional). Download and compile ITK at: http://www.itk.org

    1. Prepare your directory structure. For simplicity, I will assume everything linked to ITK will be in the same folder. This folder will contain three sub-folder:

      ITK_Source

      Contains the source code of ITK

      ITK_Build

      Will contain the build files of ITK

      ITK

      Will contain the installed version of ITK

    2. Make sure the three directories exist, and ITK_Source contains the source code.

    3. Launch a windows command and setup your environment variables for MinGW64

    4. From the main directory, configure ITK:

      $ cd ITK_Build
      $ cmake -G "MinGW Makefiles" -DCMAKE_CXX_FLAGS="-std=c++11" -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTING=OFF -DBUILD_EXAMPLES=OFF -DBUILD_SHARED_LIBS=ON -DModule_ITKReview=ON -DCMAKE_INSTALL_PREFIX=..\ITK ..\ITK_Source
      
    5. Then, compile and install ITK:

      $ mingw32-make install
      
  3. (Optional). Download and compile VTK at: http://www.vtk.org

    1. Prepare your directory structure. For simplicity, I will assume everything linked to VTK will be in the same folder. This folder will contain three sub-folder:

      VTK_Source

      Contains the source code of VTK

      VTK_Build

      Will contain the build files of VTK

      VTK

      Will contain the installed version of VTK

    2. Create a build directory, for example call VTK_build

    3. Launch a windows command and setup your environment variables for MinGW64

    4. From the main directory, configure VTK:

      $ cd VTK_Build
      $ cmake -G "MinGW Makefiles" -DCMAKE_CXX_FLAGS="-std=c++11" -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=..\VTK ..\VTK_Source
      
    5. Then, compile and install VTK:

      $ mingw32-make install
      
  4. (Optional, for extra modules only) Download the GNU scientific library from their website.

    1. Prepare your directory structure. For simplicity, I will assume everything linked to the GSL will be in the same folder. This folder will contain two sub-folder:

      GSL_Source

      Contains the source code of the GSL

      GSL

      Will contain the installed version of the GSL

    2. Launch the MSys shell

    3. Setup the environment variables for MinGW64

    4. Create a build directory and change to it (optional)

    5. Run the configure script, specifying a prefix:

      $ cd GSL_Source
      $ configure --prefix=../GSL
      
    6. Compile and install:

      $ make && make install
      
  5. Configure LithoGraphX for compilation

    1. Create a build directory

    2. Start a x64 Native Tools Command Prompt from the Visual Studio tools.

    3. Setup the MinGW64 environment variables:

      $ call mingw64.bat
      
    4. Change the current folder to the build directory you created

    5. Run cmake-gui, specifying the path to the source. For example, if you created your build folder as a sub-folder in the source tree:

      $ cmake-gui ..
      
    6. Select the MinGW Makefiles generator

    7. Check the Grouped check box to simplify the interface. This will put together all the options starting with the same work.

    8. Press the Configure button and check errors until there are none left. Typically you will need to inform the following variables have (in order in which they will appear):

      CUDA_CL_VERSION

      You need to set this to your version of Visual Studio, so here 2013.

      TIFF_INCLUDE_DIR

      This should be the include of the installation folder for libtiff.

      TIFF_LIBRARY

      This should be the file libtiff.a in the lib folder of the installation of libtiff.

      Eigen_SIGNATURE

      You need to select the file signature_of_eigen3_matrix_library in the Eigen folder.

      SIP_EXECUTABLE

      If this is not found by default, this is because you didn’t install sip in the default python location. It should be in the same folder as the python you used to compile it. If this is the case, you should activate the advanced options and make sure you select the python interpreter SIP is compiled for.

      SIP_INCLUDE_PATH

      This is the include folder, wherever the sip executable is

      SIP_PYQT5_PATH

      This should be the sip\PyQt5 folder, still where the sip executable is.

      PYTHON_LIBRARY

      To access this variable, you need to show the advance options. By default, this will look for python27.lib. If you use Anaconda, you need to install libpython and select the file libpython27.a instead.

      BUILD_EXTRA_INCLUDES

      If you didn’t install CImg in a standard path, chances are, you will need to add its path in this variable, for example if it is not found. This shouldn’t be a problem if you copy CImg.h in the src folder of LithoGraphX.

      CMAKE_BUILD_TYPE

      Set this to Release for maximal performance.

      CMAKE_INSTALL_PREFIX

      Choose the folder where LithoGraphX will be installed. If this is in Program Files, make sure the folder already exists and you can write in it, as normal programs cannot create a folder there.

      BUILD_ITK

      If you have built ITK, check this box

      BUILD_VTK

      If you have built VTK, check this box

  6. Without closing the command line, start the compilation:

    $ mingw32-make
    
  7. Then, install:

    $ mingw32-make install
    

You can contact the development team to get a zip file with all the versions we are using currently.

1.3.3.1.3. Compilation with Visual Studio 2013

Note the following process should also work with other versions of Visual Studio. However, I haven’t tested it, so it is not granted.

  1. Install Visual Studio 2013, for example the community edition which is available for free on http://www.visualstudio.com. From this version, you only need the C++ component.

  2. Install the CUDA drivers. Note: These must be installed after Visual Studio, so CUDA find it and install all the necessary components.

  3. Download the source code of SIP and PyQt5 from http://www.riverbankcomputing.com

  4. Download the version of Qt5 corresponding to the version of PyQt5 you downloaded.

  5. Download Python 2.7 or 3.4. If you are an academic, I recommend using the Anaconda distribution.

  6. Compilation of SIP
    1. Start a x64 Native Tools Command Prompt from the Visual Studio tools.

    2. Configure sip. At this time, only Visual Studio 2010 is supported, but it seems to work for Visual Studio 2013 too:

      $ python configure.py -p win32-msvc2010
      
    3. Compile and install:

      $ nmake
      $ nmake install
      
  7. Compilation of PyQt5
    1. Start the same command prompt used for SIP (you can re-use the one open for SIP)

    2. Configure PyQt5:

      $ python configure.py --spec=win32-msvc2013
      
    3. Compile and install:

      $ nmake
      $ nmake install
      
  8. Download the source code of libtiff5 from the GNUWin32 project: http://gnuwin32.sourceforge.net/packages/tiff.htm

    1. Launch the x64 Native Tools Command Prompt

    2. Compile:

      $ nmake /f Makefile.vc
      
    3. The programs may fail to compile, but the library should be fine. It will be in the libtiff folder.

  9. Download CImg from http://cimg.sourceforge.net/. Just uncompress it somewhere: this is only a header file, so there is no compilation necessary. Also, copy the header file of CImg in the src folder of LithoGraphX.

  10. (Optional). Download and compile ITK at: http://www.itk.org

    1. Prepare your directory structure. For simplicity, I will assume everything linked to ITK will be in the same folder. This folder will contain three sub-folder:

      ITK_Source

      Contains the source code of ITK

      ITK_Build

      Will contain the build files of ITK

      ITK

      Will contain the installed version of ITK

    2. Make sure the three directories exist, and ITK_Source contains the source code.

    3. Launch a VS2013 x64 Native Tools Command Prompt

    4. From the main directory, configure ITK:

      $ cd ITK_Build
      $ cmake -G "NMake Makefiles" -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTING=OFF -DBUILD_EXAMPLES=OFF -DBUILD_SHARED_LIBS=ON -DModule_ITKReview=ON -DCMAKE_INSTALL_PREFIX=..\ITK ..\ITK_Source
      
    5. Then, compile and install ITK:

      $ nmake install
      
  11. (Optional). Download and compile VTK at: http://www.vtk.org

    1. Prepare your directory structure. For simplicity, I will assume everything linked to VTK will be in the same folder. This folder will contain three sub-folder:

      VTK_Source

      Contains the source code of VTK

      VTK_Build

      Will contain the build files of VTK

      VTK

      Will contain the installed version of VTK

    2. Create a build directory, for example call VTK_build

    3. Launch a VS2013 x64 Native Tools Command Prompt

    4. From the main directory, configure VTK:

      $ cd VTK_Build
      $ cmake -G "NMake Makefiles" -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=..\VTK ..\VTK_Source
      
    5. Then, compile and install VTK:

      $ nmake install
      
  12. Create a build folder, either in or outside of the LithoGraphX folder

  13. Run cmake, and select correct the source code and build binary folders

    1. You can use either the Visual Studio 2013 Win64 or the NMake Makefiles generator.

    2. Check the Grouped check box to simplify the interface. This will put together all the options starting with the same work.

    3. Press the Configure button and check errors until there are none left. Typically you will need to inform the following variables have (in order in which they will appear):

      CUDA_CL_VERSION

      You need to set this to your version of Visual Studio, so here 2013.

      CUDA_HOST_COMPILER

      You need to put here the path to the cl program. To get this, from the command line you have opened earlier, type:

      $ where cl
      

      And copy the path writen.

      TIFF_INCLUDE_DIR

      This should be the libtiff sub-folder where you compiled libtiff in a previous step

      TIFF_LIBRARY

      This should be the file libtiff.lib in the same folder as for TIFF_INCLUDE_DIR

      Eigen_SIGNATURE

      You need to select the file signature_of_eigen3_matrix_library in the Eigen folder.

      SIP_EXECUTABLE

      If this is not found by default, this is because you didn’t install sip in the default python location. It should be in the same folder as the python you used to compile it. If this is the case, you should activate the advanced options and make sure you select the python interpreter SIP is compiled for.

      SIP_INCLUDE_PATH

      This is the include folder, wherever the sip executable is

      SIP_PYQT5_PATH

      This should be the sip\PyQt5 folder, still where the sip executable is.

      BUILD_EXTRA_INCLUDES

      If you didn’t install CImg in a standard path, chances are, you will need to add its path in this variable, for example if it is not found. This shouldn’t be a problem if you copy CImg.h in the src folder of LithoGraphX.

      CMAKE_INSTALL_PREFIX

      Choose the folder where LithoGraphX will be installed. If this is in Program Files, make sure the folder already exists and you can write in it, as normal programs cannot create a folder there.

    4. Press the Generate button

  14. If you used the NMake Makefile generator, open a x64 Native Tools Command Prompt, and compile LithoGraphX:

    $ nmake install
    

    Otherwise, open the file ALL_BUILD.vcxproj, select the Release compilation (the default is Debug), click on the INSTALL solution and compile with the Build INSTALL solution entry from the Build menu. Note: The entry will only be available if the INSTALL solution is the one currently selected on the left pane.