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, and debugging variables. I knew that ITK_LIBRARIES should be semicolon separated, but they aren’t! I wonder what I should check? Or what I did wrong in first place?
Not sure what’s wrong in your CMakeList.txt at first sight (I’d think of ITK_DIR or the way you built ITK), you may find it useful to visit the BuildAHelloWorldProgram example to get you started with a simple ITK program.
But ITK_DIR contains the files needed to include ITK_LIBRARIES: (ITKconfig.cmake) and other files as well.
I have checked the example you mentioned, and it is typically what I am doing. I think my issue concerns ITK_LIBRARIES. Do you have them separated by semicolon?
#include <iostream>
#include "itkImage.h"
using namespace std;
int main() {
cout << "Hello World!!!" << endl; // prints Hello World!!!
return 0;
}
cmake_minimum_required(VERSION 3.6.2)
project(HelloWorldTwo)
find_package(ITK REQUIRED)
include(${ITK_USE_FILE})
add_executable(HelloWorldTwo HelloWorldTwo.cpp)
target_link_libraries(HelloWorldTwo ${ITK_LIBRARIES})
MESSAGE( STATUS "ITK_DIR: " ${ITK_DIR} )
MESSAGE( STATUS "ITK_LIBRARIES: " ${ITK_LIBRARIES} )
MESSAGE( STATUS "ITK_USE_FILE: " ${ITK_USE_FILE} )
and running it with cmake -DITK_DIR:PATH=/path/cmake/ITK ../src
Maybe you can try to set ITK_DIR with cmake interface (or ccmake) instead of hard-coding it in CMakeLists.txt?
Umm, not sure what’s going on, maybe somebody else has a clue. I would recommend to try in a new build folder to start in a clean state.