链接C ++项目中的ITK头文件

时间:2018-04-26 13:06:32

标签: c++ itk

我很抱歉,如果我的问题很简单,但我尝试了很多解决方案,但没有任何结果。我正在尝试运行一个简单的HelloWorld程序,并包含ITK: itkImage.h的头文件。

运行cmake ../src来构建Makefile是可以的。 但是运行make all会出现此错误:/src/HelloWorldTwo.cpp:10:22: fatal error: itkImage.h: No such file or directory #include "itkImage.h"

在我的CMakeLists.txt文件和HelloWorldTwo.cpp下方找到 我在这里缺少什么?我试图从Eclipse和命令窗口运行make命令,但没有成功。我确信ITK_DIR包含ITKConfig.cmake,这就是为什么cmake没问题!

谢谢!

的CMakeLists.txt:

cmake_minimum_required(VERSION 2.8)
project(HelloWorldTwo)
# Find ITK.
set(ITK_DIR "/home/usr/itk/lib/cmake/ITK-4.13")
find_package(ITK REQUIRED)
include(${ITK_USE_FILE})
add_executable(HelloWorldTwo HelloWorldTwo.cpp)
target_link_libraries(HelloWorldTwo ${ITK_LIBRARIES})

HelloWorldTwo.cpp:

#include <iostream>
#include "itkImage.h"
using namespace std;
int main() {
    cout << "Hello World!!!" << endl; // prints Hello World!!!
    return 0;
}

调试CMakeLists.txt中的变量:

- ITK_DIR:/home/usr/itk/lib/cmake/ITK-4.13

- ITK_LIBRARIES:itkdouble-conversionitksysitkvnl_algoitkvnlitkv3p_netlibitknetlibitkvclITKCommonitkNetlibSlatecITKStatisticsITKTransformITKLabelMapITKMeshitkzlibITKMetaIOITKSpatialObjectsITKPathITKQuadEdgeMes​​hITKIOImageBaseITKOptimizersITKPolynomialsITKBiasCorrectionITKBioCellITKDICOMParserITKEXPATITKIOXMLITKIOSpatialObjectsITKFEMgdcmDICTgdcmMSFFITKznzITKniftiioITKgiftiiohdf5_cpp-statichdf5-staticITKIOBMPITKIOBioRadITKIOBrukerITKIOCSVITKIOGDCMITKIOIPLITKIOGEITKIOGIPLITKIOHDF5itkjpegITKIOJPEGitktiffITKIOTIFFITKIOLSMitkminc2ITKIOMINCITKIOMRCITKIOMeshITKIOMetaITKIONIFTIITKNrrdIOITKIONRRDitkpngITKIOPNGITKIOSiemensITKIOStimulateITKTransformFactoryITKIOTransformBaseITKIOTransformHDF5ITKIOTransformInsightLegacyITKIOTransformMatlabITKIOVTKITKKLMRegionGrowingitklbfgsITKOptimizersv4itkopenjpegITKVTKITKWatershedsITKReviewITKVideoCoreITKVideoIOITKVtkGlue

1 个答案:

答案 0 :(得分:0)

cmake_minimum_required(VERSION 2.8) - 您可能希望至少将此更新为2.8.12,因为这是ITK 4.13所需的最低版本。并且更新更好,尝试将其设置为3.10.2(或您拥有的任何CMake版本)。此外,ITK_LIBRARIES应该是以分号分隔的列表,而不是像这样合并。 message(STATUS "ITK_LIBRARIES: ${ITK_LIBRARIES}")应该产生类似的内容:

ITK_LIBRARIES: itkdouble-conversion;itksys;itkvnl_algo;itkvnl;itkv3p_netlib;itknetlib;itkvcl;ITKCommon;itkNetlibSlatec;ITKStatistics;ITKTransform;ITKMesh;itkzlib;ITKMetaIO;ITKSpatialObjects;ITKPath;ITKEXPAT;ITKznz;ITKniftiio;ITKgiftiio;ITKIOImageBase;ITKIOMesh;IOSTL;ITKLabelMap;ITKQuadEdgeMesh;ITKOptimizers;ITKPolynomials;ITKBiasCorrection;ITKBioCell;ITKDICOMParser;ITKIOXML;ITKIOSpatialObjects;ITKFEM;gdcmDICT;gdcmMSFF;hdf5_cpp-static;hdf5-static;ITKIOBMP;ITKIOBioRad;ITKIOCSV;ITKIOGDCM;ITKIOIPL;ITKIOGE;ITKIOGIPL;ITKIOHDF5;itkjpeg;ITKIOJPEG;itktiff;ITKIOTIFF;ITKIOLSM;ITKIOMRC;ITKIOMeta;ITKIONIFTI;ITKNrrdIO;ITKIONRRD;itkpng;ITKIOPNG;ITKIOSiemens;ITKIOStimulate;ITKTransformFactory;ITKIOTransformBase;ITKIOTransformHDF5;ITKIOTransformInsightLegacy;ITKIOTransformMatlab;ITKIOVTK;ITKKLMRegionGrowing;ITKOptimizersv4;itkopenjpeg;ITKVTK;ITKWatersheds;ITKReview;ITKVideoCore;ITKVideoIO;ITKVtkGlue