谈一谈我在win10上编译3Dslicer的经验。同样,对Slicer官网的原版英文教程不做更改,不做翻译。仅谈理解和实践经验。
目录
PREREQUISITES
Windows
CHECKOUT slicer source files
CONFIGURE and generate Slicer solution files
Customizing application build
Per-platform instructions
General information
Workaround for if the firewall is blocking git protocol
BUILD Slicer
RUN Slicer
TEST Slicer
PACKAGE Slicer
编译环境:
系统:win10
Slicer版本:Slicer4.10.1 release
编译器:VS2015
从我自身编译过程来看,从源代码来编译Slicer release版本还是比较简单的,只要遵循官方教程应该可以很轻松的编译通过。但编译过程中也会有一些坑,希望避免。
As of early 2018, Slicer migrated to Qt5. Qt4 support was removed in version 4.11.(从Slicer的4.11版开始删除了对Qt4的支持)See instructions at this labs page for the new requirements: https://www.slicer.org/wiki/Documentation/Labs/Qt5-and-VTK8
The prerequisites listed below are required to be able to configure/build/package/test Slicer.
Common Prerequisites:
Tested and recommended build environment:
Experimental/deprecated build environments:
Check out the code using git
and configure the git svn
bridge:
source directory
and the build directory
. We mean it.(尽量不要在路径中有空格)1. Clone the github repository
cd MyProjects
git clone git://github.com/Slicer/Slicer.git
The Slicer
directory is automatically created after cloning Slicer.
2. Setup the development environment:
cd Slicer
./Utilities/SetupForDevelopment.sh
For more details see Development With Git.
On Windows enter the commands above in to a bash shell, such as Git Bash (part of msysgit) or use a Git client with a graphical user interface.
3. Configure the git svn
bridge to ensure the mapping with svn revision.
git-svn is only required for core developers with svn access - other people can skip it.
cd Slicer
git svn init http://svn.slicer.org/Slicer4/trunk
git update-ref refs/remotes/git-svn refs/remotes/origin/master
git checkout master
git svn rebase
If you plan to compile Slicer to develop your own extensions and test these extensions on Slicer releases, it is convenient to download the source code directly from SVN and specify the revision number corresponding to the release you want. To do so, replace
svn co http://svn.slicer.org/Slicer4/ Slicer-r -r
Release SVN revision# Marker
4.10.0 27501 trunk
4.8.1 26813 branches/Slicer-4-8
4.8.0 26489 trunk
4.6.2 25516 branches/Slicer-4-6
4.5.0-1 24735 trunk
4.4 23774 trunk
4.3.1 22599 branches/Slicer-4-3
4.3.0 22408 trunk
More corresponding SVN revision numbers can be found here and here. The
For example, to checkout the source code associated with revision 4.8.1, you would use the following command:
svn co http://svn.slicer.org/Slicer4/branches/Slicer-4-8 Slicer-r26813 -r 26813
(因为我之前是在win7下编译过slicer4.7.0 的debug版本,在其上开发的extensions想要移植到发行版上,所以刚开始我确实是想要要编译一个release版本的Slicer来开发和测试自己的extensions。但是在采用上述的svn co的命令行方式获取源码的过程中会有错误出现,试了几次都没有成功。因此,我会直接在上述地址中https://www.slicer.org/wiki/Release_Details的GitHub上clone或者下载zip格式的源码,然后进行编译)
There are many ways of customizing Slicer's user interface or feature set. This section describes how a custom Slicer build can be configured at build-time. See an overview of various other options in this presentation.
You can configure and generate Slicer solution files using either ccmake
or cmake-gui
. To streamline this process, you can also use the SlicerCustomAppTemplate project maintained by Kitware.
Customized editions of Slicer can be generated without changing Slicer source code, just by modifying CMake variables:
Windows
Recommended: run CMake (cmake-gui) from the Windows Start menu
Set the build directory. For example: C:\Slicer-SuperBuild-Debug
or C:\Slicer-SuperBuild-Release
.
Slicer-build
directory is no longer than 50 characters (for example c:\work\Slicer\Slicer-SuperBuild
may work). In case of any build error, use very short directory names: C:\S4 for source directory, C:\S4D for debug build, C:\S4R for release build.Qt5_DIR
variable pointing to Qt5 folder such as C:\Qt\5.10.0\msvc2015_64\lib\cmake\Qt5
.CMAKE_CONFIGURATION_TYPES
to Release
in cmake-gui.Alternative option: Configure and build using command-line or batch file
Instead of using CMake (cmake-gui), it is also possible to configure by creating a .bat file that contains command-line instructions and run this .bat file each time a Slicer needs to be re-built. The examples below assume Slicer source code is in C:\S4
folder and Qt-5.10 is installed in default location.
Visual Studio 2015 in Release mode:
mkdir C:\D\S4R
cd /d C:\D\S4R
"C:\Program Files\CMake\bin\cmake.exe" -G "Visual Studio 14 2015 Win64" -DQt5_DIR:PATH=C:\Qt\5.10.0\msvc2015_64\lib\cmake\Qt5 C:\D\S4
"C:\Program Files\CMake\bin\cmake.exe" --build . --config Release
Visual Studio 2015 in Debug mode:
mkdir C:\D\S4D
cd /d C:\D\S4D
"C:\Program Files\CMake\bin\cmake.exe" -G "Visual Studio 14 2015 Win64" -DQt5_DIR:PATH=C:\Qt\5.10.0\msvc2015_64\lib\cmake\Qt5 C:\D\S4
"C:\Program Files\CMake\bin\cmake.exe" --build . --config Debug
Visual Studio 2017 with VS2015 toolset in Release mode:
mkdir C:\D\S4R
cd /d C:\D\S4R
"C:\Program Files\CMake\bin\cmake.exe" -G "Visual Studio 15 2017 Win64" -DQt5_DIR:PATH=C:\Qt\5.10.0\msvc2015_64\lib\cmake\Qt5 C:\D\S4
"C:\Program Files\CMake\bin\cmake.exe" --build . --config Release
Two projects are generated by either cmake
, ccmake
or cmake-gui
.
One of them is in the top-level bin directory Slicer-SuperBuild
and the other one is in the subdirectory Slicer-build
:
Slicer-SuperBuild/Slicer-build
Slicer-SuperBuild
manages all the external dependencies of Slicer (VTK, ITK, Python, ...). To build Slicer for the first time, run make (or build the solution file in Visual Studio) in Slicer-SuperBuild
, which will update and build the external libraries and if successful will then build the subproject Slicer-build.Slicer-SuperBuild/Slicer-build
is the "traditional" build directory of Slicer. After local changes in Slicer (or after an svn update on the source directory of Slicer), only running make (or building the solution file in Visual Studio) in Slicer-SuperBuild/Slicer-build
is necessary (the external libraries are considered built and up to date).Some firewalls will block the git protocol. A possible workaround is to configure Slicer by disabling the option Slicer_USE_GIT_PROTOCOL
. Then the http protocol will be used instead. Consider also reading https://github.com/commontk/CTK/issues/33
After configuration, start the build process in the Slicer-SuperBuild
directory
Windows (Visual Studio)
Start Windows Explorer. Need help?
Slicer-SuperBuild\Slicer.sln
in Visual StudioProject -> Build Solution
If you make local changes to Slicer, open the solution file located in the directory Slicer-SuperBuild/Slicer-build
instead. You should then be able to either build all projects or just a specific one.
Windows
Start Windows Explorer. Need help?
Run Slicer-SuperBuild/Slicer-build/Slicer.exe
Notes:
[bin/Release/SlicerQT-real.exe] exit abnormally - Report the problem.
) then one possible root cause is that you have a copy of Python26.dll
in your windows system directory (e.g., c:\Windows\System32\python26.dll
). The solution is to rename or remove the python dll in the system directory. See more details here: http://www.na-mic.org/Bug/view.php?id=1180After building, run the tests in the Slicer-SuperBuild/Slicer-build
directory
Windows (Visual Studio)
Start Windows Explorer. Need help?
Slicer-SuperBuild\Slicer.sln
in Visual StudioNote: RUN_TESTS project can be found in the CMakePredefinedTargets folder. See here for more details.
Windows (Visual Studio)
Note: Make sure to patch VS2008 using the script fix-vc9-redist-manifests.ps1
Start Windows Explorer. Need help?
Slicer-SuperBuild\Slicer-build\Slicer.sln
in Visual StudioNote: PACKAGE project can be found in the CMakePredefinedTargets folder. See here for more details.
来自:https://www.slicer.org/wiki/Documentation/Nightly/Developers/Build_Instructions