【问题标题】:Qt and OpenCv CrossCompile for Raspberry Pi ErrorRaspberry Pi 错误的 Qt 和 OpenCv 交叉编译
【发布时间】:2021-12-17 05:05:37
【问题描述】:

我正在尝试在树莓派 4 的 QT 项目中使用 opencv。我在 Linux 机器上

这是我的.pro 文件和我得到的错误。还有我的mainwindow.cpp

QT       += core gui

greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

CONFIG += c++17

# You can make your code fail to compile if it uses deprecated APIs.
# In order to do so, uncomment the following line.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000    # disables all the APIs deprecated before Qt 6.0.0

SOURCES += \
    main.cpp \
    mainwindow.cpp

HEADERS += \
    mainwindow.h

FORMS += \
    mainwindow.ui

TRANSLATIONS += \
    SCWWS_fr_FR.ts

CONFIG += lrelease
CONFIG += embed_translations

# Default rules for deployment.
qnx: target.pHere is my mainwindow.cppath = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS += target

RESOURCES += \
    resources.qrc


unix:!macx: LIBS += -L$$PWD/../../Documents/Qt-CrossCompile-RaspberryPi/raspberrypi4/sysroot/usr/lib/arm-linux-gnueabihf -lopencv_core -lopencv_highgui -lopencv_imgproc -lopencv_imgcodecs -lopencv_shape -lopencv_videoio

INCLUDEPATH += $$PWD/../../Documents/Qt-CrossCompile-RaspberryPi/raspberrypi4/sysroot/usr/include
DEPENDPATH += $$PWD/../../Documents/Qt-CrossCompile-RaspberryPi/raspberrypi4/sysroot/usr/include

这是我的 mainwindow.cpp

#include "mainwindow.h"
#include "ui_mainwindow.h"

#include <QtCore>
#include <QFontDatabase>
#include <QDebug>
#include <QImage>

//#include "opencv2/core.hpp"
//#include "opencv2/highgui.hpp"

//using namespace cv;

mainwindow::mainwindow(QWidget *parent)
    : QMainWindow(parent)
    , ui(new Ui::mainwindow)
{
    QFontDatabase::addApplicationFont(":/fonts/roboto-light.ttf");
    ui->setupUi(this);

    qDebug() << "Hello  World !";

    //cv::VideoCapture camera = VideoCapture(0);
    //
    //Mat frame;
    //camera >> frame;
    //QImage img(frame.data, frame.cols, frame.rows, frame.step, QImage::Format_RGB888);
    //ui->label->setPixmap(QPixmap::fromImage(img));
}

mainwindow::~mainwindow()
{
    delete ui;
}

这是我得到的错误

libXinerama.so.1, needed by /home/lolix/Documents/Qt-CrossCompile-RaspberryPi/raspberrypi4/sysroot/usr/lib/arm-linux-gnueabihf/libgdk-3.so.0, not found (try using -rpath or -rpath-link)

libmmal_core.so, needed by /home/lolix/Documents/Qt-CrossCompile-RaspberryPi/raspberrypi4/sysroot/usr/lib/arm-linux-gnueabihf/libavcodec.so.58, not found (try using -rpath or -rpath-link)

libmmal_vc_client.so, needed by /home/lolix/Documents/Qt-CrossCompile-RaspberryPi/raspberrypi4/sysroot/usr/lib/arm-linux-gnueabihf/libavcodec.so.58, not found (try using -rpath or -rpath-link)
.
.
.
liblapack.so.3, needed by /home/lolix/Documents/Qt-CrossCompile-RaspberryPi/raspberrypi4/sysroot/lib/libarmadillo.so.9, not found (try using -rpath or -rpath-link)

/home/lolix/Documents/Qt-CrossCompile-RaspberryPi/raspberrypi4/sysroot/usr/lib/arm-linux-gnueabihf/libopenmpt.so.0:-1: error: undefined reference to `std::random_device::_M_getentropy() const@GLIBCXX_3.4.25'

错误很快就到了,我取消了对我的代码的注释。 RP4 上的 open cv 版本是 3.2,当我将它安装在我的机器上时,它是 4.5。事件如果我使用相同的命令sudo apt-get install libopencv-dev 感谢您的帮助

**编辑**

我能够使用this response 消除这些错误。但是出现了一个新的 undefined reference to std::random_device::_M_getentropy() const@GLIBCXX_3.4.25

【问题讨论】:

  • 请使用代码块。据我了解,SO 上的代码照片是不可接受的(这可能就是你被否决的原因)。
  • 完成,感谢您的建议

标签: qt opencv raspberry-pi cross-compiling


【解决方案1】:

关于 OpenCV,我建议从源代码构建它,对于 RPi,我总是使用 docker 进行交叉编译,如 here 所述(只需删除对 openvino 的引用)。 此时你还需要为 RPi 交叉编译 Qt,但我猜你已经这样做了。

【讨论】:

  • 我按照tutorial 在我的 RP4 上安装了 opencv。我成功地用 qt creator 交叉编译了一个 qt 应用程序。当我尝试将 opencv 包含到我的项目中时,就会出现问题。我不知道接下来要做什么,我应该再次rsync 吗?
  • 现在有一个新错误,undefined reference to std::random_device::_M_getentropy() const@GLIBCXX_3.4.25'
  • 试试看this
  • 如果我理解正确,我必须使用与编译qt相同的编译器?
  • 你必须在你的 Linux 机器上为 RPi 交叉编译 OpenCV,然后你交叉编译你的应用程序,将你的可执行文件与你刚刚交叉编译的这个 opencv 库链接起来。如果一切都很好,你可以移动RPi 上的可执行和交叉编译的库..
猜你喜欢
  • 2016-01-21
  • 1970-01-01
  • 1970-01-01
  • 2012-06-28
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-04-10
相关资源
最近更新 更多