2

I am sorry if my problem is trivial, but I tried many solutions and nothing works out. I am trying to run a simple HelloWorld program, and make an inclusion of header file of ITK: itkImage.h.

Running cmake ../src to build the Makefile is okay. But running make all gives this error: /src/HelloWorldTwo.cpp:10:22: fatal error: itkImage.h: No such file or directory #include "itkImage.h"

Find below my CMakeLists.txt file and HelloWorldTwo.cpp What I am missing here? I tried to run make command from Eclipse and from command window, but no success. I am sure the ITK_DIR contains ITKConfig.cmake, that's why cmake is okay!

Thank you!

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;
}

Debugging the variables in CMakeLists.txt:

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

-- ITK_LIBRARIES: itkdouble-conversionitksysitkvnl_algoitkvnlitkv3p_netlibitknetlibitkvclITKCommonitkNetlibSlatecITKStatisticsITKTransformITKLabelMapITKMeshitkzlibITKMetaIOITKSpatialObjectsITKPathITKQuadEdgeMeshITKIOImageBaseITKOptimizersITKPolynomialsITKBiasCorrectionITKBioCellITKDICOMParserITKEXPATITKIOXMLITKIOSpatialObjectsITKFEMgdcmDICTgdcmMSFFITKznzITKniftiioITKgiftiiohdf5_cpp-statichdf5-staticITKIOBMPITKIOBioRadITKIOBrukerITKIOCSVITKIOGDCMITKIOIPLITKIOGEITKIOGIPLITKIOHDF5itkjpegITKIOJPEGitktiffITKIOTIFFITKIOLSMitkminc2ITKIOMINCITKIOMRCITKIOMeshITKIOMetaITKIONIFTIITKNrrdIOITKIONRRDitkpngITKIOPNGITKIOSiemensITKIOStimulateITKTransformFactoryITKIOTransformBaseITKIOTransformHDF5ITKIOTransformInsightLegacyITKIOTransformMatlabITKIOVTKITKKLMRegionGrowingitklbfgsITKOptimizersv4itkopenjpegITKVTKITKWatershedsITKReviewITKVideoCoreITKVideoIOITKVtkGlue

1 Answers1

0

cmake_minimum_required(VERSION 2.8) - you might want to update this to 2.8.12 at least, as that is the minimum required version for ITK 4.13. And newer being better, try setting it to 3.10.2 (or whichever CMake version you have). Also, ITK_LIBRARIES should be semicolon-separated list, not merged like that. message(STATUS "ITK_LIBRARIES: ${ITK_LIBRARIES}") should produce something like:

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.

Dženan
  • 3,329
  • 3
  • 31
  • 44
  • I have updated cmake version, but it didn't changed the output. About the missed semicolon: I have no idea why it is like that. Do you have any guess? Or what I should check about it? – matlab user Apr 26 '18 at 14:56