-
Notifications
You must be signed in to change notification settings - Fork 14
Building
Before building, see if we have binaries for your operating system here.
- You will need CMake to build SMILI installed on your OS. Get it from cmake.org.
- You will need the Insight Toolkit (ITK) built and/or installed on your OS. ITK 4.6.x or above for the DICOM plugin and vector image support. ITK 4.13.3 is recommended. ITK 5 support is available.
- You will need Qt 4 Framework. Qt 5 and 6 are supported experimentally at the moment via this branch.
- You will need the Visualisation Toolkit (VTK) built and/or installed on your OS. VTK 6.3 is recommended, VTK 7, 8 and 9 are also supported and VTK 5 needed for the SSM plugin.
- To build support for Freesurfer MGH (*.mgh, *.mgz) files and other ITKIO options, ensure ITK is built with MGHIO etc. and turn on BUILD_ITKIO_SUPPORT (as of > v1.0.4)
Windows installers are provided here. For building tutorials, see videos on YouTube found on the SMILI channel: https://www.youtube.com/channel/UCD-hU6IF2qGlz7roexAUj1Q
Ensure you have the latest Windows SDK for your Visual Studio. In VS2022, you can select the SDK by selecting it in the installer or when you modify the install. I had issues with CMake always selecting an older SDK, which had rc.exe missing and caused a 'the specified task executable "rc.exe" could not be run.... too long command' error when building SMILX. I had to specify cmake-gui to use the latest one by setting CMAKE_SYSTEM_VERSION=10.0.26100.0 BEFORE configuring via the advice on this page.. This is likely due to a faulty SDK release previously, but fixed in recent versions.
It is best to grab the Qt 4.6 or above binary from the Qt-x64 project of SourceForge (http://sourceforge.net/projects/qtx64/). Or the installer I use, which I have provided just in case.
You can use Qt 5.13+ if you build the 'topic-qt5' branch and use the online installer from Qt. Select the Archive list in the installer to load available Qt versions, then use 5.15.2 to get the Qt 5 binaries for Windows.
See video: https://www.youtube.com/watch?v=gsW-1HpE2nQ
Consult the ITK documentation: http://www.itk.org/Wiki/ITK/Configuring_and_Building
- Download ITK from itk.org.
- Open CMake-GUI and select the source firectory and create a directory for the binaries
- Select your build environment/compiler
- Turn BUILD_SHARED_LIBS to ON and testing and examples OFF.
- Configure and Generate as no other specific settings are required.
- Open solution etc. and build making sure the architecture and build type (Release etc.) is consistent throughout.
- Had to remove unary_function inheritance in itkImageAlgorithm because it is removed in C++17
- Had to rename lrintf to opj_lrintf in opj_includes.h from OpenJPEG third party module in ITK
- Add the const qualifier to struct dircos_comp at gdcmIPPSorter.cxx (line 40-57) to
bool operator()( dircos_key const & lhs, dircos_key const & rhs ) const {
- May need to add /FS flag (if above doesn't work) to CMAKE_CXX_FLAGS in the CMake config when building to avoid the "'const gdcm::dircos_comp' would lose some const-volatile qualifiers" error.
- Had to remove unary_function inheritance in itkImageAlgorithm because it is removed in C++17
- Had to fix libtiff error '__ucrt_int_to_float already defined in itktiff' for Windows SDK 10.0.26100.0. Used the info in this GitHub issue. by modifying Modules\ThirdParty\TIFF\src\itktiff\tif_config.h.in replacing line 461 with
# if defined(_MSC_VER) && _MSC_VER < 1900
See video: https://www.youtube.com/watch?v=h9IzPHPj37U
Consult the VTK documentation: http://www.vtk.org/Wiki/VTK/Configure_and_Build
- Download VTK from vtk.org
- Open CMake-GUI and select the source firectory and create a directory for the binaries
- Select your build environment/compiler
- Turn BUILD_SHARED_LIBS to ON and testing and examples OFF.
- Turn VTK_Group_Qt to ON. It may not find Qt even if you've got it from the Qt-x64 project, just point the QT_QMAKE_EXECUTABLE to the qmake.exe file in the unzipped binary bin directory.
- If wanting to build the Animate plugin, you will need to turn Module_vtkFFMPEG to ON. You will need the FFMPEG binaries. Get the shared and dev files from http://ffmpeg.zeranoe.com/builds/ and fill in the required fields when VTK cant find them. You may get issues with the FFMPEG API changing every release. A nice summary of changes can be found at http://sgros.blogspot.com.au/2013/01/deprecated-functions-in-ffmpeg-library.html
- Configure and Generate as no other specific settings are required.
- Open solution etc. and build making sure the architecture and build type (Release etc.) is consistent throughout.
- Had to add include below for QPainterPath in vtkQtStringToImage.cxx and vtkQtLabelRenderStrategy.cxx
#include <QPainterPath>
No issues in VTK 9
I set my environment variable FFMPEG_DIR after downloading FFMPEG windows build binaries from Gyan.dev to the path where I extracted it. VTK IOFFMPEG CMake config seems to have lost the FFMPEG_DIR search capability in v9 or later, see here that uses the FFMPEG_DIR environment variable. I had to add the following lines to the beginning of my IOFFMPEG/CMakeLists.txt file
set(FFMPEG_ROOT $ENV{FFMPEG_DIR})
mark_as_advanced(FFMPEG_ROOT)
This was the cleaniest and easiest way for VTK 9, otherwise VTK wouldn't detect my FFMPEG binaries. If you're building it for earlier versions, you may need my very old guide for FFMPEG changes that VTK might need.
Set VTK_MODULE_ENABLE_VTK_IOFFMPEG to ON and build as normal.
See video: https://www.youtube.com/watch?v=JQtg_dR0qVI
- Open CMake-GUI and select the source firectory and create a directory for the binaries
- Select your build environment/compiler
- Qt 4 library will likely not be found so just point the QT_QMAKE_EXECUTABLE to the qmake.exe file in the unzipped binary bin directory. If you're only trying to build the GUI-independent sub-library milxSMILI, then just set BUILD_VIEWER to OFF.
- CMake should automatically find the previous VTK and ITK libraries you built. If not, change the ITK_DIR and VTK_DIR appropriately.
- Set the ZLIB variable manually on Windows, just reuse the ITK ZLIB libraries and headers. Otherwise you'll get the error "zlib.h" not found.
- Configure and Generate as no other specific settings are required.
- Open solution etc. and build making sure the architecture and build type (Release etc.) is consistent throughout.
Once you have SMILI built, you can run sMILX from the bin directory of your build type. Copy the ITK and VTK DLLs from their builds, copy the 'load_dependencies.bat' from the SMILI parent directory to the bin directory, startup the Qt terminal for Windows that comes with your Qt install and run this Batch file. It will setup Qt properly for use with sMILX and then you can start the application normally.
An easier approach can also be just building the installer via NSIS. Install the NSIS framework. CMake will automatically create the PACKAGE project within the VS SMILI solution if SMILI is setup and built correctly. One must add the paths to the VTK, QT and SMILI DLLs to the properties of the PACKAGE project under the VC++ Directories Executables section. Then build the PACKAGE project just as any project and BUNDLE FIXUP will create the installer.
Software such as Graphviz, MikTex and TexStudio currently interfere with SMILI packaging via NSIS because they install Qt DLLs into the path causing incorrect Qt DLLs to be installed and causing hell. Recommend uninstalling these or remove their references within the PATH variable.
The new approach is using Winqtdeploy for the installer to setup Qt and MSVS distributables properly. I had to ensure that the CMake Configuration Type is set to only Release in cmake-gui. It also needs VCINSTALLDIR set to your current VS if you have multiple VS's installed.
This plugin just requires ITK 4.5 or above.
This plugin requires vtkFFMPEGIO module to be built in VTK.
This plugin requires PythonQt 2.1 or above to be built AND installed.
This plugin requires VTK 5.8 or 5.10.1 and the SSM source code found here. Select the CMake option SSM_LOCAL and build SMILI as usual.
Sometimes its more convenient to build via the command line. You can do this via the NMake Makefiles or NMake Makefiles JOM option in CMake. Basic steps include:
- Opening the VS 2019 (or whichever VS you're using) `x64 Native Tools Command Prompt for VS 2019' to open the VS build env.
- (Optional) To enable multi-threaded builds, I used JOM from https://wiki.qt.io/Jom and copied into the VS 2019 VC/bin directory.
- Running CMake from it
"C:\Program Files\CMake\bin\cmake-gui.exe"
- Choose the NMake Makefiles JOM option
- Configure as normal (see above)
- Change directory to build directory
- Build the library
jom -j 12
where -j 12 is building across 12 threads.
Follow instructions for your distro below. Generally, just install CMake, ITK 4.x and VTK 6.x from your distro's repository. The remaining aspects are covered in a video on youtube found on the SMILI channel: https://www.youtube.com/channel/UCD-hU6IF2qGlz7roexAUj1Q
-
From the SMILI source directory create a build directory, change to it and run CMake Curses GUI
mkdir build cd build ccmake .. -
Select your build environment/compiler with the -G option when you run 'ccmake ..' if you want to use other IDEs like Codeblocks etc.
-
Configure and Generate as no other specific settings are required.
-
Open solution etc. and build making sure the architecture and build type (Release etc.) is consistent throughout.
This plugin requires PythonQt 2.1 or above to be installed from the repository.
Simply install the VTK 9, Qt 5 and ITK 5 libraries from the repository then build SMILI.
I did so with the following commands for the experimental branch for SMILI:
sudo apt-get install vtk9 libvtk9-qt-dev #VTK and Qt
sudo apt-get install libqt5webenginewidgets5 libqt5webkit5-dev qtwebengine5-dev # Qt WebEngine stuff
sudo apt-get install libinsighttoolkit5-dev #ITK
Not there are difficulties in building the Python bindings for Qt 5 version due to issues with the older PySide2 that is required. This is resolved with PySide6 and Qt 6 versions of SMILI.
VTK Qt 6 version is not available in the repository, so we have to do it ourselves. Then build SMILI as normal.
If you are attempting to build SMILI Python bindings, please look at the dedicated Python Bindings page.
- Install Qt 6 from the repository
sudo apt-get install qt6-base-dev qt6-3d-dev qt6-webengine-dev qt6-base-private-dev qt6-webengine-private-dev qt6-wayland-dev
- Install Qt6 QML/Quick WebEngine requirements for VTK and SMILI (Important, otherwise you'll get a Qt6Quick error in CMake)
sudo apt-get install qml6-module-qtwebengine qml6-module-qtwebengine-controlsdelegates
- Build VTK with Qt 6 enabled from source (only VTK with Qt 5 is available from the repository).
SMILI can be built entirely from the libraries from the official repository. I installed the following packages from a clean install:
- cmake-curses-gui, libvtk7-qt-dev, libinsighttoolkit4-dev, qtwebengine5-dev. Note that VTK 9.1 also works now.
I then switched to the 'topic-qt5' branch and cmake build as usual.
I had to modify the shell script (apps/smilx/smilx.sh.in) by adding JVM to the LD_LIBRARY_PATH for Ubuntu 22.04
fi
@SMILX_LD_LIBRARY_PATH@="/usr/lib/jvm/default-java/lib;/usr/lib/jvm/default-java/lib/server;${dirname}/lib:${@SMILX_LD_LIBRARY_PATH@}"
Then building the Debian package as normal with 'sudo make package'.
Debian packages are provided here. Ubuntu 18.04 no longer ships with VTK 6 with Qt 4, but instead ships with Qt 5. It also ships with a newer GCC that breaks older Qt and VTK libraries. There are two methods for building SMILI with Qt 4 or Qt 5. Use the following SMILI branch to build for Ubuntu 18.04.
ITK 4.12 is provided in the repository and so is Qt 4 libraries/headers etc.
Install it from the repository using the packages: libqt4-dev and libqtwebkit-dev.
We need to build VTK 6.3 or VTK 7.0 with Qt 4 before building SMILI. I got CMake errors with VTK 6.3 and VTK 7.0.0, so used a newer patched version of 7.1.0 from here. The error is due to having too new version of GCC (see this answer). I also built VTK 6.3.0 with the simple changes in the answer.
There is a bug with Qt4 WebKit for the GCC compiler with Ubuntu 18.04. I have created a special branch with the help assistant disabled as a workaround.
Use the SMILI's Qt 5 branch to build with VTK 6+ and ITK 4. Note that this branch is still under development. You will also need to install qtwebengine5-dev package to ensure WebEngine Widgets is found.
RPM packages are provided here. All the libraries to build SMILI are available in the repository, but in unusual install directories that CMake has difficulty finding. VTK, ITK and Qt 4 are all available and easy to setup. I had to do the following for ITK parts as Fedora did not do the dependencies properly (use 'yum install'):
- Install g++ - package name is unusual: gcc-c++
- Install GDCM - gdcm-devel.x86_64 gdcm.x86_64
- Install FFTW - fftw-devel.x86_64 fftw.x86_64
- Install VXL - vxl-devel.x86_64
- Wouldn't detect ITK, so set it to path - /usr/lib64/cmake/InsightToolkit
- Add -fpermissive to CMAKE CXX Flags
VTK 5 is not provided and needs to be built. Set CMAKE_CXX_FLAGS as -fpermissive -std=c++98 -DGLX_GLXEXT_LEGACY.
I installed the official VTK, ITK and Qt6 libraries using pacman. I then used the topic-itk5 branch of SMILI to build it because the official ITK was version 5, so use this branch for ITKv5 support. Make sure to update your repos with pacman -Syu if you encounter missing .so errors. I had to install additional libraries like imath alembic liblas opencascade pdal libpqxx ospray intel-oneapi-mkl, but this could have been due to not updating my distro.
The easiest approach I found that supported both QtWebEngine and macdeployqt packaging working properly was through Mac Ports
#Install Qt5 and WebEngine
sudo port install qt5 qt5-qtwebengine
#Install VTK with Qt5 support via qt5 variant
sudo port install vtk +qt5
#Install ITK
sudo port install InsightToolkit4
I have created a temporary branch called topic-macos that has the changes I needed for CMakefile configs to build the MacOSX packages. You then build it with
sudo make package
sudo make package
Yes twice, probably because the current CMake macdeployqt config is sub-optimal
Using Xcode 15.1, SMILI builds with ITK 4.13.3 and VTK 9.4.0 and Qt 6 on topic-qt5 branch caused crashes on loading windows.
Homebrew's Qt5 works with in source builds, but the macdeployqt would not function correctly, not correctly setting up dylibs and packages failed at application startup.
Building my own Qt5 from source was difficult because configure would not let me build QtWebEngine because 'platform not supported'.
Build on ITK 5 is now supported on the topic-itk5 branch, but this is experimental and untested. Had to remove unary_function inheritance in itkImageAlgorithm because it is removed in C++17, same as VS2022 for Windows above.
I had issues with Homebrew's VTK package which has HDF5 library problems, so built my own VTK. I used Homebrew's Qt 6, but it had RPATH issues when packaging, so using Qt 6.8 directly from qt.io fixed the issues (see reported issue).
Using latest Xcode 15.4 at time of writing, currently VTK 9.4.2 or earlier does not build with char_traits error, potentially be fixed with upcoming 9.5.0 (see here). You will need to use MacOSX version earlier than 15.4 or build VTK from the repository from the master branch.