Qt版本6.2.4,Vtk版本为9.2.2,Release正常编译运行,为何Debug模式编译通过,运行报错。
以下是源码:
//QtWidgetsApplication1.h
#pragma once
#include <QtWidgets/QMainWindow>
#include "ui_QtWidgetsApplication1.h"
#include <vtkSphereSource.h>
#include <vtkPolyDataMapper.h>
#include <vtkActor.h>
#include <vtkRenderer.h>
#include <vtkRenderWindow.h>
#include <vtkGenericOpenGLRenderWindow.h>
#include <vtkNamedColors.h>
#include <vtkProperty.h>
#include <vtkSmartPointer.h>
#include "vtkAutoInit.h"
VTK_MODULE_INIT(vtkRenderingOpenGL2);
VTK_MODULE_INIT(vtkInteractionStyle);
VTK_MODULE_INIT(vtkRenderingVolumeOpenGL2);
VTK_MODULE_INIT(vtkRenderingFreeType);
#include <pcl/io/pcd_io.h>
#include <pcl/io/ply_io.h>
#include <pcl/point_types.h>
#include <pcl/point_cloud.h>
#include <pcl/visualization/pcl_visualizer.h>
#include <pcl/visualization/histogram_visualizer.h>
#include <pcl/visualization/pcl_plotter.h>
class QtWidgetsApplication1 : public QMainWindow
{
Q_OBJECT
public:
QtWidgetsApplication1(QWidget *parent = nullptr);
~QtWidgetsApplication1();
private:
Ui::QtWidgetsApplication1Class ui;
std::vector<pcl::PointCloud<pcl::PointXYZ>::Ptr> cloud_vec;
std::vector<int> cloud_index;
pcl::PointCloud<pcl::PointXYZ> cloud;
boost::shared_ptr<pcl::visualization::PCLVisualizer> viewer;
int point_size = 3;
private slots:
void on_pushButton_clicked();//读取点云
};
//QtWidgetsApplication1.cpp
#include "QtWidgetsApplication1.h"
using namespace std;
QtWidgetsApplication1::QtWidgetsApplication1(QWidget* parent)
: QMainWindow(parent)
{
ui.setupUi(this);
viewer.reset(new pcl::visualization::PCLVisualizer("viewer", false));
vtkNew<vtkGenericOpenGLRenderWindow> window;
window->AddRenderer(viewer->getRendererCollection()->GetFirstRenderer());
ui.qvtkWidget->setRenderWindow(window.Get());
ui.qvtkWidget->update();
}
QtWidgetsApplication1::~QtWidgetsApplication1()
{}
void QtWidgetsApplication1::on_pushButton_clicked()
{
if (pcl::io::loadPCDFile<pcl::PointXYZ>("bunny.pcd", cloud) == -1) //* load the file
{
qDebug() << "Couldn't read pcd file \n";
return;
}
int size = static_cast<int>(cloud.size());
viewer.reset(new pcl::visualization::PCLVisualizer("viewer", false));
vtkNew<vtkGenericOpenGLRenderWindow> window;
window->AddRenderer(viewer->getRendererCollection()->GetFirstRenderer());
ui.qvtkWidget->setRenderWindow(window.Get());
viewer->addPointCloud<pcl::PointXYZ>(cloud.makeShared(), std::to_string(cloud_vec.size() - 1));
//设置点云大小
viewer->setPointCloudRenderingProperties(pcl::visualization::PCL_VISUALIZER_POINT_SIZE, point_size, std::to_string(cloud_vec.size() - 1));
viewer->resetCamera();
ui.qvtkWidget->update();
}
运行结果及详细报错内容
调试信息显示缺少Vtk相关的Pdb文件,可是编译成功的Vtk本身就没有对应的VtkChartsCore-9.2d.pdb等文件,求解答?