gpt4 book ai didi

c++ - 在 C++ 项目中链接 ITK 头文件

转载 作者:塔克拉玛干 更新时间:2023-11-03 07:41:14 26 4
gpt4 key购买 nike

如果我的问题是微不足道的,我很抱歉,但我尝试了很多解决方案,但没有任何效果。我正在尝试运行一个简单的 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

最佳答案

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;ITKifEXPAT;ITKgiftinzio;ITK;ITK ITKIOImageBase;ITKIOMesh;IOSTL;ITKLabelMap;ITKQuadEdgeMes​​h;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.

关于c++ - 在 C++ 项目中链接 ITK 头文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50043784/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com