【发布时间】:2018-04-24 22:24:30
【问题描述】:
如果问题很原始,我很抱歉,但我无法解决问题。我想使用 ITK 库在 C++ 中读取 nifti 图像。我在 Github 上使用过代码:https://gist.github.com/rafamanzo/a3c258f4f74e898e9418。这是读取图像的非常简单的代码。然后我使用CMake 将ITK 配置到我的项目中。以下是我的CMakeLists.txt文件:
cmake_minimum_required(VERSION 2.8)
project(MyProject)
set(CMAKE_INSTALL_PREFIX "/home/itk")
set(ITK_DIR "/home/itk/InsightToolkit-4.13.0/bin/")
set(VTK_DIR "/home/vtk/VTK-8.1.0/bin/")
find_package(ITK REQUIRED)
find_package(VTK REQUIRED)
if (ITKVtkGlue_LOADED)
find_package(VTK REQUIRED)
include(${VTK_USE_FILE})
else()
find_package(ItkVtkGlue REQUIRED)
include(${ItkVtkGlue_USE_FILE})
set(Glue ItkVtkGlue)
endif()
include(${ITK_USE_FILE})
include(${VTK_USE_FILE})
add_executable(MyProject mainFile.cxx)
target_link_libraries(MyProject ${ITK_LIBRARIES})
"cmake .." 运行成功。 但是“make all”给了我一个错误:
make[2]: *** No rule to make target '/home/vtk/VTK-8.1.0/bin/lib/libvtkRenderingOpenGL2.so', needed by 'MyProject'. Stop.
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/MyProject.dir/all' failed
make[1]: *** [CMakeFiles/MyProject.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
令人惊讶的是,当我从 Eclipse 构建项目时,我遇到了另一个错误:
./bin/CMakeFiles/feature_tests.o: In function `main':
/home/MyProject/Debug/../bin/CMakeFiles/feature_tests.c:34: multiple definition of `main'
makefile:32: recipe for target 'MyProject' failed
./bin/CMakeFiles/3.6.2/CompilerIdC/CMakeCCompilerId.o:/home/MyProject/Debug/../bin/CMakeFiles/3.6.2/CompilerIdC/CMakeCCompilerId.c:540: first defined here
/usr/bin/ld: cannot find -l/home/vtk/VTK-8.1.0/bin/lib/libvtkRenderingContextOpenGL2-8.1.so
collect2: error: ld returned 1 exit status
make: *** [MyProject] Error 1
我很确定配置ITK 很容易,尤其是我以前做过,但只能使用 ImageFileReader。任何帮助深表感谢。谢谢。
【问题讨论】: