我是ITK的新手,我做了以下步骤来安装ITK并使用它在VS2010中编程
以下是我的简单代码......
#include <iostream>
#include <Core/Common/include/itkImage.h>
using namespace itk;
using namespace std;
int main()
{
return 0;
}
上面的代码返回
Cannot open include file: 'itkConfigure.h'
我试着搜索那个标题,但没有运气。但是在C:\InsightToolkit-4.3.1\Modules\Core\Common\src
我找到了 itkConfigure.h.in 文件。我对如何处理这个.in文件真的很无能为力。任何帮助都是最受欢迎的..
答案 0 :(得分:3)
设置项目的最简单方法是再次使用CMake。尝试使用CMakeLists.txt和main.cpp创建项目。 CMakeLists.txt应该有:
cmake_minimum_required(VERSION 2.8 FATAL_ERROR)
project(ItkTest)
find_package(ITK REQUIRED)
include(${ITK_USE_FILE})
add_executable(MyTest main.cpp)
target_link_libraries(MyTest ITKCommon)
所以说你在一个名为ItkProject的目录中创建这两个文件,然后从 Visual Studio命令提示符中创建:
cd <path to ItkProject>
mkdir build
cd build
cmake .. -DITK_DIR="<path to build dir of ITK>"
<path to build dir of ITK>
是您运行CMake以配置ITK项目的地方。它将包含ITK.sln文件,但关键的是它还应该包含一个名为ITKConfig.cmake的文件。这是在cmake命令find_package(ITK REQUIRED)
中搜索的文件 - 如果CMake找不到它,配置将失败。
一旦找到它,就会设置一堆CMake变量,然后您可以在自己的CMakeLists.txt中使用它们,包括ITK_USE_FILE
。
当您再调用include(${ITK_USE_FILE})
时,会继续设置包含路径,库搜索路径和编译器标志等内容。路径<path to ItkProject>/Core/Common/include
将添加到包含目录中,因此在main.cpp中,您只需执行以下操作:
#include <Core/Common/include/itkImage.h>
#include "itkImage.h"
无论如何,运行CMake后的最终结果应该是解决方案文件<path to ItkProject>\build\ItkTest.sln
,它已经准备就绪,可以使用ITK。
答案 1 :(得分:0)
我检查了\ ItkConfig.cmake,并且那里定义的路径应该匹配物理路径,如果ITK构建未受影响(目录未重命名)就是这种情况。
# The ITK source tree.
# For backward compatibility issues we still need to define this variable, although
# it is highly probable that it will cause more harm than being useful.
# Use ITK_INCLUDE_DIRS instead, since ITK_SOURCE_DIR may point to non-existent directory
IF(NOT ITK_LEGACY_REMOVE)
SET(ITK_SOURCE_DIR "C:/ITK320")
ENDIF(NOT ITK_LEGACY_REMOVE)
# The ITK include file directories.
SET(ITK_INCLUDE_DIRS "C:/ITK320-build;C:/ITK320/Code/Algorithms;C:/ITK320/Code/BasicFilters;C:/ITK320/Code/Common;C:/ITK320/Code/Numerics;C:/ITK320/Code/IO;C:/ITK320/Code/Numerics/FEM;C:/ITK320/Code/Numerics/NeuralNetworks;C:/ITK320/Code/SpatialObject;C:/ITK320/Utilities/MetaIO;C:/ITK320/Utilities/NrrdIO;C:/ITK320-build/Utilities/NrrdIO;C:/ITK320/Utilities/DICOMParser;C:/ITK320-build/Utilities/DICOMParser;C:/ITK320-build/Utilities/expat;C:/ITK320/Utilities/expat;C:/ITK320/Utilities/nifti/niftilib;C:/ITK320/Utilities/nifti/znzlib;C:/ITK320/Utilities/itkExtHdrs;C:/ITK320-build/Utilities;C:/ITK320/Utilities;C:/ITK320/Code/Numerics/Statistics;C:/ITK320/Utilities/vxl/v3p/netlib;C:/ITK320/Utilities/vxl/vcl;C:/ITK320/Utilities/vxl/core;C:/ITK320-build/Utilities/vxl/v3p/netlib;C:/ITK320-build/Utilities/vxl/vcl;C:/ITK320-build/Utilities/vxl/core;C:/ITK320-build/Utilities/gdcm;C:/ITK320/Utilities/gdcm/src")
# The ITK library directories.
SET(ITK_LIBRARY_DIRS "C:/ITK320-build/bin")