Michailina
Michailina

Reputation: 15

What is causing the fatal error: SimpleITK.h: No such file or directory? (C++ project with cmake)

I get fatal error: SimpleITK.h: No such file or directory after executing make -j8 trying to build my project.

I have no expirience with SimpleITK. Here are the steps that followed to install SimpleITK:

I downloaded the source code of SimpleITK using git:

git clone https://github.com/SimpleITK/SimpleITK.git

After downloading SimpleITK’s source code i executed the following commands in the parent of the SimpleITK source directory to configure the SuperBuild:

mkdir SimpleITK-build
cd SimpleITK-build
cmake ../SimpleITK/SuperBuild

After that I used make -j8 to build SimpleITK.

I have set the required CMake Variables ( **SimpleITK_DIR **and **ITK_DIR **) in the SimpleITK-build/CMakeCache.txt like this (information taken from https://simpleitk.readthedocs.io/en/master/link_CppCMake_docs.html):

SimpleITK_DIR:PATH=/testproject/external/SimpleITK-build/SimpleITK-build
ITK_DIR:PATH=/testproject/external/SimpleITK-build/ITK-build

My C++ project structure:

 -testproject
 ---build
 ---exec
 ---external
 -----HighFive
 -----SimpleITK
 -----SimpleITK-build
 -----yaml-cpp
 ---include
 ---src

My CmakeLists.txt in the testproject folder:

cmake_minimum_required(VERSION 3.16)
set(CMAKE_CUDA_ARCHITECTURES 70)
project(
    project_name
    VERSION 0.1
    LANGUAGES CXX CUDA
)
find_package(Boost REQUIRED)
find_package(OpenCV REQUIRED)
find_package(SimpleITK)
include_directories( ${OpenCV_INCLUDE_DIRS} )
add_subdirectory(external/HighFive-2.4.1)
add_subdirectory(external/yaml-cpp)
add_subdirectory(src)
add_subdirectory(exec)

and the second one in the testproject/exec folder

add_executable(vg vg.cpp)
target_compile_features(vg PUBLIC cxx_std_17)
target_link_libraries(vg PRIVATE loader_library renderer_library)
target_link_libraries (vg ${SimpleITK_LIBRARIES} )

I am really new to c++ and simpleitk. How can i fix this problem? The project without simpleitk part has no issues.

Upvotes: 0

Views: 98

Answers (0)

Related Questions