我想讓一個qt程序與opencv一起工作沒有成功。 Qt,獨自工作。並且獨立的opencv可以工作(在Eclipse中)。鏈接錯誤Opencv Qt'_ZN2cv6String10deallocateEv
這裏是mainwindow.cpp文件我很簡單的C代碼:
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <opencv2/opencv.hpp>
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow)
{
ui->setupUi(this);
cv::Mat image = cv::imread("my_image.png");
cv::imshow("Display", image);
}
MainWindow::~MainWindow()
{
delete ui;
}
現在我的qmake的文件,其中有可能是問題,因爲聯: QT + =核心GUI
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = test
TEMPLATE = app
INCLUDEPATH += /usr/local/include/opencv
SOURCES += main.cpp\
mainwindow.cpp
HEADERS += mainwindow.h
FORMS += mainwindow.ui
LIBS += -L/usr/local/lib \
-lopencv_core \
-lopencv_highgui \
-lopencv_imgcodecs
而最糟糕的(或最佳)爲末,我可怕的錯誤:
warning: libopencv_core.so.3.3, needed by /usr/local/lib/libopencv_imgcodecs.so, may conflict with libopencv_core.so.2.4
error: error adding symbols: DSO missing from command line /usr/local/lib/libopencv_core.so.3.3:
error: collect2: error: ld returned 1 exit status
我真的很希望有人會閱讀我的信息並提供解決方案。也許最好的應該是卸載並重新安裝opencv或qt,我不知道。
感謝,
忘了添加最重要的錯誤:'mainwindow.o:未定義引用符號'_ZN2cv6String10deallocateEv'' – GaelG