无法链接到vtk 6.3 / usr / bin / ld:找不到-lvtkCommon

时间:2016-05-19 00:35:49

标签: c++ compilation linker linker-errors vtk

我从源代码安装了vtk 6.3,我正在尝试使用以下cmake编译我的项目:

cmake_minimum_required (VERSION 2.6 FATAL_ERROR)

project      (paintsquad)
find_package (Qt5 REQUIRED COMPONENTS Widgets Core)
find_package (VTK 6.3 REQUIRED)
find_package (PCL 1.8.0 REQUIRED)

include_directories (/usr/local/lib)
INCLUDE_DIRECTORIES (${PROJECT_SOURCE_DIR})
include_directories (${PCL_INCLUDE_DIRS})
link_directories    (${PCL_LIBRARY_DIRS})
add_definitions     (${PCL_DEFINITIONS})

...

QT5_WRAP_CPP (project_HEADERS_MOC   ${project_HEADERS})
QT5_WRAP_UI  (project_FORMS_HEADERS ${project_FORMS})

ADD_DEFINITIONS (${QT_DEFINITIONS})

ADD_EXECUTABLE  (pcl_visualizer ${project_SOURCES}
                                ${project_FORMS_HEADERS}
                                ${project_HEADERS_MOC}
                                ${project_hpp_files})

TARGET_LINK_LIBRARIES (pcl_visualizer ${PCL_LIBRARIES})
qt5_use_modules (pcl_visualizer Widgets)

但我收到这些链接器错误:

/usr/bin/ld: cannot find -lvtkCommon
/usr/bin/ld: cannot find -lvtkFiltering
/usr/bin/ld: cannot find -lvtkImaging
/usr/bin/ld: cannot find -lvtkGraphics
/usr/bin/ld: cannot find -lvtkGenericFiltering
/usr/bin/ld: cannot find -lvtkIO
/usr/bin/ld: cannot find -lvtkRendering
/usr/bin/ld: cannot find -lvtkVolumeRendering
/usr/bin/ld: cannot find -lvtkHybrid
/usr/bin/ld: cannot find -lvtkWidgets
/usr/bin/ld: cannot find -lvtkInfovis
/usr/bin/ld: cannot find -lvtkGeovis
/usr/bin/ld: cannot find -lvtkViews
/usr/bin/ld: cannot find -lvtkCharts
collect2: error: ld returned 1 exit status

我以前从源代码安装了vtk 5.8,所以现在我必须安装。 我正在使用ubuntu 16。

1 个答案:

答案 0 :(得分:2)

问题是我之前使用vtk 5.8版编译了pcl,并且尝试使用vtk版本6.3,后来我安装了它。

所以我首先删除了我的vtk 5.8然后用vtk版本6.3重新编译pcl来解决这个问题。