【发布时间】:2015-04-04 15:36:11
【问题描述】:
我想在vtk中编译this的例子,其中包括以下包含文件:
#include <vtkSmartPointer.h>
#include <vtkObjectFactory.h>
#include <vtkRenderWindow.h>
#include <vtkRenderWindowInteractor.h>
#include <vtkRenderer.h>
#include <vtkActor.h>
// headers needed for this example
#include <vtkImageViewer2.h>
#include <vtkDICOMImageReader.h>
#include <vtkInteractorStyleImage.h>
#include <vtkActor2D.h>
#include <vtkTextProperty.h>
#include <vtkTextMapper.h>
// needed to easily convert int to std::string
#include <sstream>
最初它应该使用CMakeLists.txt-file 编译,如下所示:
cmake_minimum_required(VERSION 2.8)
PROJECT(ReadDICOMSeries)
find_package(VTK REQUIRED)
include(${VTK_USE_FILE})
add_executable(ReadDICOMSeries MACOSX_BUNDLE ReadDICOMSeries)
if(VTK_LIBRARIES)
target_link_libraries(ReadDICOMSeries ${VTK_LIBRARIES})
else()
target_link_libraries(ReadDICOMSeries vtkHybrid vtkWidgets)
endif()
问题是:当我简单地复制这段代码并编译它时,我得到了很多引用错误(例如:Undefined reference to 'vtkDICOMImageReader::SetDirectoryName(char const*)')。这使我假设我应该将一些库链接到它。不幸的是,CMakeLists 文件没有告诉我哪些库。我怎样才能知道呢?
【问题讨论】:
-
运行 CMake 时,VTK 安装路径是否正确?
-
是的,一切都很好。
-
只有这个例子有问题,而其他工作正常吗?如果你已经编译成功 vtk,并且使用 CMake 设置项目,那么要包含的库已经由 cmake 管理(感谢 include(${VTK_USE_FILE}), ${VTK_LIBRARIES})。您是否可能在发布模式下编译了 VTK,并尝试在调试中编译示例,或者相反?
-
问题是我不想使用 CMake,我想使用 g++ 并通过 -l
添加库。但我不知道我必须添加哪些库。