ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

PCL安装及遇到的问题“/usr/bin/vtk“ but this file does not exist

2021-07-05 19:32:23  阅读:1412  来源: 互联网

标签:bin cmake file get vtk sudo pcl apt install


文章目录

PCL安装过程

Ubuntu18.04安装PCL(详细教程)

1.1 安装依赖

sudo apt-get update  
sudo apt-get install git build-essential linux-libc-dev
sudo apt-get install cmake cmake-gui
sudo apt-get install libusb-1.0-0-dev libusb-dev libudev-dev
sudo apt-get install mpi-default-dev openmpi-bin openmpi-common 
sudo apt-get install libflann1.9 libflann-dev
sudo apt-get install libeigen3-dev 这个需要自己下载正确版本安装
sudo apt-get install libboost-all-dev
sudo apt-get install libvtk7.1-qt    (以下三个换成libvtk6,我的6可以7不能使)
sudo apt-get install libvtk7.1 
sudo apt-get install libvtk7-qt-dev(按照错误提示一步一步安装所需要的东西) 
sudo apt-get install libqhull* libgtest-dev
sudo apt-get install freeglut3-dev pkg-config
sudo apt-get install libxmu-dev libxi-dev
sudo apt-get install mono-complete
sudo apt-get install openjdk-8-jdk openjdk-8-jre

1.2 下载编译

git clone https://github.com/PointCloudLibrary/pcl.git 
cd pcl 
mkdir release 
cd release
cmake -DCMAKE_BUILD_TYPE=None -DCMAKE_INSTALL_PREFIX=/usr \ -DBUILD_GPU=ON-DBUILD_apps=ON -DBUILD_examples=ON \ -DCMAKE_INSTALL_PREFIX=/usr .. 
make  
sudo make install

cmake …出现错误1:

The imported target "vtkRenderingPythonTkWidgets" references the file
   "/usr/lib/x86_64-linux-gnu/libvtkRenderingPythonTkWidgets.so"
but this file does not exist.  Possible reasons include:
* The file was deleted, renamed, or moved to another location.
* An install or uninstall procedure did not complete successfully.
* The installation package was faulty and contained
   "/usr/lib/cmake/vtk-6.2/VTKTargets.cmake"
but not all the files it references.

-- The imported target "vtk" references the file
   "/usr/bin/vtk"
but this file does not exist.  Possible reasons include:
* The file was deleted, renamed, or moved to another location.
* An install or uninstall procedure did not complete successfully.
* The installation package was faulty and contained
   "/usr/lib/cmake/vtk-6.2/VTKTargets.cmake"
but not all the files it references

千万不可sudo apt install python-vtk解决,会导致ROS的依赖丢失,ROS不可用。
建议使用sudo ln -s /usr/bin/vtk6 /usr/bin/vtk

这里需要注意一点,vtk有安装7.0/7.1,也有6.2版本。我这里试了sudo ln -s /usr/bin/vtk7 /usr/bin/vtk不行,建立软链接之后依然出现问题,必须使用vtk6才行。

cmake …出现错误2:

CMake Error at /usr/lib/cmake/vtk-7.1/vtkModuleAPI.cmake:120 (message):
  Requested modules not available:
 
    vtkRenderingOpenGL
Call Stack (most recent call first):
  /usr/lib/cmake/vtk-7.1/VTKConfig.cmake:89 (vtk_module_config)
  cmake/OpenCVDetectVTK.cmake:6 (find_package)
  CMakeLists.txt:597 (include)

在opencv/cmake目录下,将OpencvDetectVTK.cmake文件中前几行的对应模块名后面加个2

/home/lyp/third_part/opencv/cmake/OpencvDetectVTK.cmake

vtkRenderingOpenGL修改成vtkRenderingOpenGL2

# VTK 6.x components
find_package(VTK QUIET COMPONENTS vtkRenderingOpenGL2 vtkInteractionStyle vtkRenderingLOD vtkIOPLY vtkFiltersTexture vtkRenderingFreeType vtkIOExport NO_MODULE)

ROS系统被删除问题3:

万一ROS丢失了怎样修补?

参考链接: https://blog.csdn.net/haiyinshushe/article/details/84256137

sudo apt install libpcl-dev
sudo apt install libvtk6-java
sudo apt install libvtk6-jni
sudo apt install libvtk6-dev
sudo apt install libvtk6-qt-dev
sudo apt install ros-melodic-pcl-conversions
sudo apt install ros-melodic-perception-pcl
sudo apt-get install ros-melodic-desktop-full

运行roscore,出现错误:

Resource not found: roslaunch
ROS path [0]=/opt/ros/noetic/share/ros
ROS path [1]=/opt/ros/noetic/share
The traceback for the exception was written to the log file

我的关机重启竟然好了,如果不行那就再解决吧。


至此,PCL能用了:
test_pcl.cpp

#include <iostream>
#include <pcl/common/common_headers.h>
#include <pcl/io/pcd_io.h>
#include <pcl/visualization/pcl_visualizer.h>
#include <pcl/visualization/cloud_viewer.h>
#include <pcl/console/parse.h>

int main(int argc, char **argv) {
  std::cout << "Test PCL !" << std::endl;
  pcl::PointCloud<pcl::PointXYZRGB>::Ptr point_cloud_ptr (new pcl::PointCloud<pcl::PointXYZRGB>);
  uint8_t r(255), g(15), b(15);
  for (float z(-1.0); z <= 1.0; z += 0.05) {
    for (float angle(0.0); angle <= 360.0; angle += 5.0) {
      pcl::PointXYZRGB point;
      point.x = 0.5 * cosf (pcl::deg2rad(angle));
      point.y = sinf (pcl::deg2rad(angle));
      point.z = z;
      uint32_t rgb = (static_cast<uint32_t>(r) << 16 | static_cast<uint32_t>(g) << 8 | static_cast<uint32_t>(b));
      point.rgb = *reinterpret_cast<float*>(&rgb);
      point_cloud_ptr->points.push_back (point);
    }
    if (z < 0.0) {
      r -= 12;
      g += 12;
    }
    else {
      g -= 12;
      b += 12;
    }
  }

  point_cloud_ptr->width = (int) point_cloud_ptr->points.size ();
  point_cloud_ptr->height = 1;

  pcl::visualization::CloudViewer viewer ("test");
  viewer.showCloud(point_cloud_ptr);
  while (!viewer.wasStopped()){ };
  return 0;
}

CMakeLists.txt

cmake_minimum_required(VERSION 2.6)
project(test_pcl)

find_package(PCL 1.8 REQUIRED)

include_directories(${PCL_INCLUDE_DIRS})
link_directories(${PCL_LIBRARY_DIRS})
add_definitions(${PCL_DEFINITIONS})

add_executable(test_pcl test_pcl.cpp)

target_link_libraries (test_pcl ${PCL_LIBRARIES})

install(TARGETS test_pcl RUNTIME DESTINATION bin)

然后

mkdir build
cd build
cmake ..
make
./test_pcl

测试效果(说明PCL安装成功):
在这里插入图片描述

标签:bin,cmake,file,get,vtk,sudo,pcl,apt,install
来源: https://blog.csdn.net/qq_41821678/article/details/118491849

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有