我尝试编译一些Qt项目,但出现链接器错误。 我想做一个读取蓝牙低功耗(BLE)Gatt特性的小项目。我有一个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 64位(MSVC 2017)。
,而不的发现代理i'm能够编译该项目初始化的线路。
我已经启动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