最近工作需要,产品界面中需要用到显示实时波形,于是使用了QCustomPlot类库。这里写一下遇到的问题和解决。
E:\HH-PM001\build-detecter-Desktop_Qt_5_8_0_MinGW_32bit-Debug\debug\qcustomplot.o:-1: In function `ZN11QCustomPlot7savePdfERK7QStringiiN3QCP9ExportPenES2_S2_':
E:\HH-PM001\trunk\QCustomPlot\qcustomplot.cpp:14244: error: undefined reference to `_imp___ZN8QPrinterC1ENS_11PrinterModeE'
E:\HH-PM001\trunk\QCustomPlot\qcustomplot.cpp:14246: error: undefined reference to `_imp___ZN8QPrinter15setOutputFormatENS_12OutputFormatE'
E:\HH-PM001\trunk\QCustomPlot\qcustomplot.cpp:14247: error: undefined reference to `_imp___ZN8QPrinter12setColorModeENS_9ColorModeE'
E:\HH-PM001\trunk\QCustomPlot\qcustomplot.cpp:14248: error: undefined reference to `_imp___ZNK8QPrinter11printEngineEv'
E:\HH-PM001\trunk\QCustomPlot\qcustomplot.cpp:14249: error: undefined reference to `_imp___ZNK8QPrinter11printEngineEv'
E:\HH-PM001\trunk\QCustomPlot\qcustomplot.cpp:14244: error: undefined reference to `_imp___ZN8QPrinterD1Ev'
E:\HH-PM001\trunk\QCustomPlot\qcustomplot.cpp:14244: error: undefined reference to `_imp___ZN8QPrinterD1Ev'
collect2.exe:-1: error: error: ld returned 1 exit status
认真看了一下,原来我忘记在工程文件.pro文件中添加下面的语句了。
QT += printsupport
添加后,一切正常,因为qcustomplot.cpp中使用到了打印功能,所以这个是需要添加的。