1. ITK Configuring and Building in VisualStudio
With Visual Studio 2010 on Windows 7 (32-bit):
- Launch the CMake GUI by starting a Visual Studio Command Prompt (Start->Programs-> Microsoft Visual Studio 2010->Visual Studio Tools->Visual Studio Command Prompt) and running "cmake-gui"
- Next to "Where is the source code:", click "Browse Source..." and navigate to where you cloned the repository with Git.
- Next to "Where to build the binaries:", select "Browse Build..." and select a place to build the ITK library. I like to use c:\build\ITK. This directory should NOT be inside the directory where you cloned the repository.
- Click "Configure", and then specify "Visual Studio 10" as the generator for this project.
- Choose your build options. I like to UNCHECK BUILD_EXAMPLES and BUILD_TESTING as they speed up the build process significantly.
- Click "Generate".
- Open Visual Studio 2010
- Open Project
- Navigate to the Build directory you specified through CMake
- Open the ALL_BUILD project
- From the Build menu, choose "Build Solution" (or "Build ALL_BUILD")
五、编译Helloword
(1)任何位置建立目录 hello, hello/bin, hello用来存放源程序, bin 为程序编译目标。拷贝ITK下的Examples\Installation中的CMakeLists.txt和HelloWorld.cxx到hello目录下。
(2)使用 CMake 进行配置:打开Cmake,选择源目录和目标目录路径,
Where is the source code: 点击 Browse, 选择 D:\Projects\ITK Projects\hello
Where to build the binaries: 点击 Browse, 选择 D:\Projects\ITK Projects\hello\bin
如图6。
(3)点击Configure(假设没有找到 ITK 路径, 则须要手动指定)。等全部条目都变成白色后再点击Generate生成项目,如图7。
(4)双击打开 hello/bin下生成的HelloWorld.sln, 自己主动进入VS 2010,如图8, 编译并执行项目。如图9,至此成功。
參考资料:
[1] http://www.itk.org/Wiki/ITK/Configuring_and_Building/VisualStudio
[2] http://www.bokeyi.com/ll/2014/04/06/itk%E5%9C%A8vs2010%E4%B8%8B%E7%BC%96%E8%AF%91%E5%AE%89%E8%A3%85%E4%BD%BF%E7%94%A8/