代碼如下:
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 個無法決議的外部命令
uj5u.com熱心網友回復:
pro檔案要么使用SOURCES += XXX.cpp,要么使用LIBS += -lXXX。其余的情況就是MSVC連接不到MinGW構建的檔案了。
uj5u.com熱心網友回復:
您好 我現在解決了這個問題,但是在后續出現了另外一個問題:
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 個無法決議的外部命令
這個錯誤您知道應該怎么解決嗎,搞了幾天了都沒什么思路
uj5u.com熱心網友回復:
看看.lib庫中有哪些匯出函式。使用這個命令:dumpbin /all /rawdata:none 你的庫.lib
再進行對比一下
uj5u.com熱心網友回復:
無法決議的外部符,說明是庫檔案路徑配置不對,極大可能是因為庫檔案配置的時候教程版本和自己的版本不一樣,名字不對。轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/118440.html
標籤:Qt
下一篇:求教
