Почему компиляция Qt BluetoothDiscoveryAgent приводит к ошибке компоновщика - PullRequest
0 голосов
/ 03 февраля 2019

Я пытаюсь скомпилировать небольшой проект Qt, но получаю ошибку компоновщика.Я хочу сделать небольшой проект, который будет читать характеристики Гатта Bluetooth Low Energy (BLE).У меня есть встроенная плата, на которой работает BLE.

Когда я запускаю компилятор, я получаю предупреждения / ошибки:

qtmain.lib(qtmain_winrt.obj):-1: Warnung: LNK4099: PDB "qtmain.pdb" wurde nicht mit "qtmain.lib(qtmain_winrt.obj)" oder an "C:\Users\Kennis\Documents\build-Bachlerorarbeit-Qt_5_11_2_for_UWP_64bit_MSVC_2017-Profile\release\qtmain.pdb" gefunden; Objekt wird verknüpft, als ob keine Debuginformationen vorhanden wären.

widget.obj:-1: error LNK2019: unresolved external symbol ""__declspec(dllimport) public: __cdecl QBluetoothDeviceDiscoveryAgent::QBluetoothDeviceDiscoveryAgent(class QObject *)" (__imp_??0QBluetoothDeviceDiscoveryAgent@@QEAA@PEAVQObject@@@Z)" referenced in function""public: __cdecl Widget::Widget(class QWidget *)" (??0Widget@@QEAA@PEAVQWidget@@@Z)".

widget.obj:-1: error LNK2019: unresolved external symbol ""__declspec(dllimport) public: virtual __cdecl QBluetoothDeviceDiscoveryAgent::~QBluetoothDeviceDiscoveryAgent(void)" (__imp_??1QBluetoothDeviceDiscoveryAgent@@UEAA@XZ)" referenced in function ""public: virtual void * __cdecl QBluetoothDeviceDiscoveryAgent::`scalar deleting destructor'(unsigned int)" (??_GQBluetoothDeviceDiscoveryAgent@@UEAAPEAXI@Z)".

widget.obj:-1: error LNK2001: unresolved external symbol""public: virtual struct QMetaObject const * __cdecl QBluetoothDeviceDiscoveryAgent::metaObject(void)const " (?metaObject@QBluetoothDeviceDiscoveryAgent@@UEBAPEBUQMetaObject@@XZ)".

widget.obj:-1: error LNK2001: unresolved external symbol ""public: virtual struct QMetaObject const * __cdecl QBluetoothDeviceDiscoveryAgent::metaObject(void)const " (?metaObject@QBluetoothDeviceDiscoveryAgent@@UEBAPEBUQMetaObject@@XZ)".

widget.obj:-1: error LNK2001: unresolved external symbol ""public: virtual void * __cdecl QBluetoothDeviceDiscoveryAgent::qt_metacast(char const *)" (?qt_metacast@QBluetoothDeviceDiscoveryAgent@@UEAAPEAXPEBD@Z)".
: 

Я работаю в Windows 10 с Qt5.11.2 для UWP 64bit (MSVC 2017).

без строки init Агента обнаружения, я могу скомпилировать проект.

Я запустил Qmake и перестроил несколько раз.

main.cpp:

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    Widget w;
    w.show();

    return a.exec();
}

widget.cpp:

#include "widget.h"
#include "ui_widget.h"

#include <QtBluetooth/QBluetoothDeviceDiscoveryAgent>
#include <QtBluetooth/QBluetoothDeviceInfo>


Widget::Widget(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::Widget)
{
    ui->setupUi(this);

    discoveryAgent = new QBluetoothDeviceDiscoveryAgent(this);
}

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

widget.h

#ifndef WIDGET_H
#define WIDGET_H

#include <QWidget>

#include <QtBluetooth/QBluetoothDeviceDiscoveryAgent>
#include <QtBluetooth/QBluetoothDeviceInfo>


namespace Ui {
class Widget;
}

class Widget : public QWidget
{
    Q_OBJECT

public:
    explicit Widget(QWidget *parent = nullptr);
    ~Widget();

    QBluetoothDeviceDiscoveryAgent *discoveryAgent;

private:
    Ui::Widget *ui;
};

#endif // WIDGET_H

bachelorarbeit.pro:

#-------------------------------------------------
#-------------------------------------------------
#
# Project created by QtCreator 2019-02-02T21:22:40
#
#-------------------------------------------------

QT       += core gui

greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

TARGET = Bachlerorarbeit
TEMPLATE = app

# The following define makes your compiler emit warnings if you use
# any feature of Qt which has been marked as deprecated (the exact 
warnings
# depend on your compiler). Please consult the documentation of the
# deprecated API in order to know how to port your code away from it.
DEFINES += QT_DEPRECATED_WARNINGS

# You can also make your code fail to compile if you use deprecated APIs.
# In order to do so, uncomment the following line.
# You can also select to disable deprecated APIs only up to a certain 
version of Qt.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000    # disables all the 
APIs deprecated before Qt 6.0.0

CONFIG += c++11

SOURCES += \
        main.cpp \
        widget.cpp

HEADERS += \
        widget.h

FORMS += \
        widget.ui



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