QtCreator中Qt5.6.2使用QVTKWidget报LNK2019

cehui120 2018-10-01 07:47:34

代码如下:
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);

// 鼠标追踪
this->setMouseTracking(true);
ui->centralWidget->setMouseTracking(true);

CreateStatusBar();

//初始化显示控件 为创建的对象开辟空间
qvtkWidget = new QVTKWidget(this);
viewer.reset (new pcl::visualization::PCLVisualizer ("viewer", false));
//这两句代码很重要,
qvtkWidget->SetRenderWindow (viewer->getRenderWindow ());
viewer->setupInteractor (qvtkWidget->GetInteractor (),qvtkWidget->GetRenderWindow ());
setCentralWidget(qvtkWidget);
qvtkWidget->update ();

}


报错:
mainwindow.obj : error LNK2019: 无法解析的外部符号 "__declspec(dllimport) public: __cdecl QVTKWidget::QVTKWidget(class QWidget *,class QFlags<enum Qt::WindowType>)" (__imp_??0QVTKWidget@@QEAA@PEAVQWidget@@V?$QFlags@W4WindowType@Qt@@@@@Z),该符号在函数 "public: __cdecl MainWindow::MainWindow(class QWidget *)" (??0MainWindow@@QEAA@PEAVQWidget@@@Z) 中被引用
mainwindow.obj : error LNK2019: 无法解析的外部符号 "__declspec(dllimport) public: virtual __cdecl QVTKWidget::~QVTKWidget(void)" (__imp_??1QVTKWidget@@UEAA@XZ),该符号在函数 "public: virtual void * __cdecl QVTKWidget::`scalar deleting destructor'(unsigned int)" (??_GQVTKWidget@@UEAAPEAXI@Z) 中被引用
mainwindow.obj : error LNK2001: 无法解析的外部符号 "public: virtual class QVTKInteractor * __cdecl QVTKWidget::GetInteractor(void)" (?GetInteractor@QVTKWidget@@UEAAPEAVQVTKInteractor@@XZ)
mainwindow.obj : error LNK2001: 无法解析的外部符号 "public: virtual class vtkRenderWindow * __cdecl QVTKWidget::GetRenderWindow(void)" (?GetRenderWindow@QVTKWidget@@UEAAPEAVvtkRenderWindow@@XZ)
mainwindow.obj : error LNK2001: 无法解析的外部符号 "public: virtual void __cdecl QVTKWidget::SetRenderWindow(class vtkRenderWindow *)" (?SetRenderWindow@QVTKWidget@@UEAAXPEAVvtkRenderWindow@@@Z)
mainwindow.obj : error LNK2001: 无法解析的外部符号 "public: virtual class vtkImageData * __cdecl QVTKWidget::cachedImage(void)" (?cachedImage@QVTKWidget@@UEAAPEAVvtkImageData@@XZ)
mainwindow.obj : error LNK2001: 无法解析的外部符号 "protected: virtual void __cdecl QVTKWidget::contextMenuEvent(class QContextMenuEvent *)" (?contextMenuEvent@QVTKWidget@@MEAAXPEAVQContextMenuEvent@@@Z)
mainwindow.obj : error LNK2001: 无法解析的外部符号 "protected: virtual void __cdecl QVTKWidget::dragEnterEvent(class QDragEnterEvent *)" (?dragEnterEvent@QVTKWidget@@MEAAXPEAVQDragEnterEvent@@@Z)
mainwindow.obj : error LNK2001: 无法解析的外部符号 "protected: virtual void __cdecl QVTKWidget::dragLeaveEvent(class QDragLeaveEvent *)" (?dragLeaveEvent@QVTKWidget@@MEAAXPEAVQDragLeaveEvent@@@Z)
mainwindow.obj : error LNK2001: 无法解析的外部符号 "protected: virtual void __cdecl QVTKWidget::dragMoveEvent(class QDragMoveEvent *)" (?dragMoveEvent@QVTKWidget@@MEAAXPEAVQDragMoveEvent@@@Z)
mainwindow.obj : error LNK2001: 无法解析的外部符号 "protected: virtual void __cdecl QVTKWidget::dropEvent(class QDropEvent *)" (?dropEvent@QVTKWidget@@MEAAXPEAVQDropEvent@@@Z)
mainwindow.obj : error LNK2001: 无法解析的外部符号 "protected: virtual void __cdecl QVTKWidget::enterEvent(class QEvent *)" (?enterEvent@QVTKWidget@@MEAAXPEAVQEvent@@@Z)
mainwindow.obj : error LNK2001: 无法解析的外部符号 "protected: virtual bool __cdecl QVTKWidget::event(class QEvent *)" (?event@QVTKWidget@@MEAA_NPEAVQEvent@@@Z)
mainwindow.obj : error LNK2001: 无法解析的外部符号 "protected: virtual void __cdecl QVTKWidget::focusInEvent(class QFocusEvent *)" (?focusInEvent@QVTKWidget@@MEAAXPEAVQFocusEvent@@@Z)
mainwindow.obj : error LNK2001: 无法解析的外部符号 "protected: virtual void __cdecl QVTKWidget::focusOutEvent(class QFocusEvent *)" (?focusOutEvent@QVTKWidget@@MEAAXPEAVQFocusEvent@@@Z)
mainwindow.obj : error LNK2001: 无法解析的外部符号 "public: virtual bool __cdecl QVTKWidget::isAutomaticImageCacheEnabled(void)const " (?isAutomaticImageCacheEnabled@QVTKWidget@@UEBA_NXZ)
mainwindow.obj : error LNK2001: 无法解析的外部符号 "protected: virtual void __cdecl QVTKWidget::keyPressEvent(class QKeyEvent *)" (?keyPressEvent@QVTKWidget@@MEAAXPEAVQKeyEvent@@@Z)
mainwindow.obj : error LNK2001: 无法解析的外部符号 "protected: virtual void __cdecl QVTKWidget::keyReleaseEvent(class QKeyEvent *)" (?keyReleaseEvent@QVTKWidget@@MEAAXPEAVQKeyEvent@@@Z)
mainwindow.obj : error LNK2001: 无法解析的外部符号 "protected: virtual void __cdecl QVTKWidget::leaveEvent(class QEvent *)" (?leaveEvent@QVTKWidget@@MEAAXPEAVQEvent@@@Z)
mainwindow.obj : error LNK2001: 无法解析的外部符号 "public: virtual double __cdecl QVTKWidget::maxRenderRateForImageCache(void)const " (?maxRenderRateForImageCache@QVTKWidget@@UEBANXZ)
mainwindow.obj : error LNK2001: 无法解析的外部符号 "public: virtual struct QMetaObject const * __cdecl QVTKWidget::metaObject(void)const " (?metaObject@QVTKWidget@@UEBAPEBUQMetaObject@@XZ)
mainwindow.obj : error LNK2001: 无法解析的外部符号 "protected: virtual void __cdecl QVTKWidget::mouseMoveEvent(class QMouseEvent *)" (?mouseMoveEvent@QVTKWidget@@MEAAXPEAVQMouseEvent@@@Z)
mainwindow.obj : error LNK2001: 无法解析的外部符号 "protected: virtual void __cdecl QVTKWidget::mousePressEvent(class QMouseEvent *)" (?mousePressEvent@QVTKWidget@@MEAAXPEAVQMouseEvent@@@Z)
mainwindow.obj : error LNK2001: 无法解析的外部符号 "protected: virtual void __cdecl QVTKWidget::mouseReleaseEvent(class QMouseEvent *)" (?mouseReleaseEvent@QVTKWidget@@MEAAXPEAVQMouseEvent@@@Z)
mainwindow.obj : error LNK2001: 无法解析的外部符号 "protected: virtual void __cdecl QVTKWidget::moveEvent(class QMoveEvent *)" (?moveEvent@QVTKWidget@@MEAAXPEAVQMoveEvent@@@Z)
mainwindow.obj : error LNK2001: 无法解析的外部符号 "protected: virtual bool __cdecl QVTKWidget::nativeEvent(class QByteArray const &,void *,long *)" (?nativeEvent@QVTKWidget@@MEAA_NAEBVQByteArray@@PEAXPEAJ@Z)
mainwindow.obj : error LNK2001: 无法解析的外部符号 "protected: virtual bool __cdecl QVTKWidget::paintCachedImage(void)" (?paintCachedImage@QVTKWidget@@MEAA_NXZ)
mainwindow.obj : error LNK2001: 无法解析的外部符号 "public: virtual class QPaintEngine * __cdecl QVTKWidget::paintEngine(void)const " (?paintEngine@QVTKWidget@@UEBAPEAVQPaintEngine@@XZ)
mainwindow.obj : error LNK2001: 无法解析的外部符号 "protected: virtual void __cdecl QVTKWidget::paintEvent(class QPaintEvent *)" (?paintEvent@QVTKWidget@@MEAAXPEAVQPaintEvent@@@Z)
mainwindow.obj : error LNK2001: 无法解析的外部符号 "public: virtual int __cdecl QVTKWidget::qt_metacall(enum QMetaObject::Call,int,void * *)" (?qt_metacall@QVTKWidget@@UEAAHW4Call@QMetaObject@@HPEAPEAX@Z)
mainwindow.obj : error LNK2001: 无法解析的外部符号 "public: virtual void * __cdecl QVTKWidget::qt_metacast(char const *)" (?qt_metacast@QVTKWidget@@UEAAPEAXPEBD@Z)
mainwindow.obj : error LNK2001: 无法解析的外部符号 "protected: virtual void __cdecl QVTKWidget::resizeEvent(class QResizeEvent *)" (?resizeEvent@QVTKWidget@@MEAAXPEAVQResizeEvent@@@Z)
mainwindow.obj : error LNK2001: 无法解析的外部符号 "public: virtual void __cdecl QVTKWidget::setAutomaticImageCacheEnabled(bool)" (?setAutomaticImageCacheEnabled@QVTKWidget@@UEAAX_N@Z)
mainwindow.obj : error LNK2001: 无法解析的外部符号 "public: virtual void __cdecl QVTKWidget::setMaxRenderRateForImageCache(double)" (?setMaxRenderRateForImageCache@QVTKWidget@@UEAAXN@Z)
mainwindow.obj : error LNK2001: 无法解析的外部符号 "public: virtual void __cdecl QVTKWidget::showEvent(class QShowEvent *)" (?showEvent@QVTKWidget@@UEAAXPEAVQShowEvent@@@Z)
mainwindow.obj : error LNK2001: 无法解析的外部符号 "protected: virtual void __cdecl QVTKWidget::wheelEvent(class QWheelEvent *)" (?wheelEvent@QVTKWidget@@MEAAXPEAVQWheelEvent@@@Z)
debug\ConvexHull.exe : fatal error LNK1120: 36 个无法解析的外部命令
...全文
2627 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
苏州一中球王 2021-01-28
  • 打赏
  • 举报
回复
刚刚也遇到了这个问题,解决了 其实就是lib文件的问题,检查一下自己的库目录和附加依赖项目中的lib文件是否配置正确了 尤其是注意自己是debug还是release下进行编译的,要与你在项目属性中配置的release 还是debug一致
cehui120 2019-08-15
  • 打赏
  • 举报
回复
无法解析的外部符,说明是库文件路径配置不对,极大可能是因为库文件配置的时候教程版本和自己的版本不一样,名字不对。
彩阳 2018-10-13
  • 打赏
  • 举报
回复
看看.lib库中有哪些导出函数。使用这个命令: dumpbin /all /rawdata:none 你的库.lib 再进行对比一下
cehui120 2018-10-08
  • 打赏
  • 举报
回复
引用 1 楼 jiangcaiyang123 的回复:
pro文件要么使用SOURCES += XXX.cpp,要么使用LIBS += -lXXX。 其余的情况就是MSVC连接不到MinGW构建的文件了。
您好 我现在解决了这个问题,但是在后续出现了另外一个问题: Generic Warning: In ..\..\..\Rendering\Core\vtkPolyDataMapper.cxx, line 28 Error: no override found for 'vtkPolyDataMapper'. Warning: In ..\..\..\Rendering\Core\vtkInteractorStyleSwitchBase.cxx, line 43 vtkInteractorStyleSwitchBase (000001467B461B90): Warning: Link to vtkInteractionStyle for default style selection. Generic Warning: In ..\..\..\Rendering\Core\vtkPolyDataMapper.cxx, line 28 Error: no override found for 'vtkPolyDataMapper'. 我在网上搜索之后都是说
#include<vtkAutoInit.h>
VTK_MODULE_INIT(vtkRenderingOpenGL)
VTK_MODULE_INIT(vtkPolyDataMapper)
VTK_MODULE_INIT(vtkInteractionStyle)
这样写可以避免,但是我这样写了之后运行出错:
main.obj : error LNK2019: 无法解析的外部符号 "void __cdecl vtkPolyDataMapper_AutoInit_Construct(void)" (?vtkPolyDataMapper_AutoInit_Construct@@YAXXZ),该符号在函数 "public: __cdecl vtkPolyDataMapper_ModuleInit::vtkPolyDataMapper_ModuleInit(void)" (??0vtkPolyDataMapper_ModuleInit@@QEAA@XZ) 中被引用
mainwindow.obj : error LNK2001: 无法解析的外部符号 "void __cdecl vtkPolyDataMapper_AutoInit_Construct(void)" (?vtkPolyDataMapper_AutoInit_Construct@@YAXXZ)
moc_mainwindow.obj : error LNK2001: 无法解析的外部符号 "void __cdecl vtkPolyDataMapper_AutoInit_Construct(void)" (?vtkPolyDataMapper_AutoInit_Construct@@YAXXZ)
main.obj : error LNK2019: 无法解析的外部符号 "void __cdecl vtkPolyDataMapper_AutoInit_Destruct(void)" (?vtkPolyDataMapper_AutoInit_Destruct@@YAXXZ),该符号在函数 "public: __cdecl vtkPolyDataMapper_ModuleInit::~vtkPolyDataMapper_ModuleInit(void)" (??1vtkPolyDataMapper_ModuleInit@@QEAA@XZ) 中被引用
mainwindow.obj : error LNK2001: 无法解析的外部符号 "void __cdecl vtkPolyDataMapper_AutoInit_Destruct(void)" (?vtkPolyDataMapper_AutoInit_Destruct@@YAXXZ)
moc_mainwindow.obj : error LNK2001: 无法解析的外部符号 "void __cdecl vtkPolyDataMapper_AutoInit_Destruct(void)" (?vtkPolyDataMapper_AutoInit_Destruct@@YAXXZ)
debug\ConvexHull.exe : fatal error LNK1120: 2 个无法解析的外部命令
这个错误您知道应该怎么解决吗,搞了几天了都没什么思路
彩阳 2018-10-02
  • 打赏
  • 举报
回复
pro文件要么使用SOURCES += XXX.cpp,要么使用LIBS += -lXXX。 其余的情况就是MSVC连接不到MinGW构建的文件了。

16,224

社区成员

发帖
与我相关
我的任务
社区描述
Qt 是一个跨平台应用程序框架。通过使用 Qt,您可以一次性开发应用程序和用户界面,然后将其部署到多个桌面和嵌入式操作系统,而无需重复编写源代码。
社区管理员
  • Qt
  • 亭台六七座
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧