Hello everyone!
I'm a student in electical engineering, having some troubles with C++ / Qt Programming. For a students project, I've to program a simple app on Sailfish OS (Device: Jolla 1, QtBluetooth 5.2) which listens to UDP datagrams (that works well) and hands them over to a Bluetooth SPP connection (rfcomm protocol). It's mainly just a control software for a RGBW lamp, which gets connected via BT.
UDP and Bluetooth are in the same project, accessing the same include-space.
While my UDP connection works flawlessly, the Bluetooth code causes the linker to stop and hand out the error:
\home\mersdk\share\LightCubeServer\src\btconn.cpp: 14: Error: undefined reference to `QBluetoothServer::QBluetoothServer(QBluetoothServ iceInfo::Protocol, QObject*)'
After spending two weekends of reading documentations, I've no clue on what to do anymore. I even attached the corresponding include files to the project, which didn't change anything.
The Header file btconn.h:
#include <QtCore/QObject>
#include <QtBluetooth/QBluetoothServer>
QT_FORWARD_DECLARE_CLASS(QBluetoothServer)
{
Q_OBJECT
public:
explicit BtConn
(QObject *parent
= 0);
// Constructor void startServer(const QBluetoothAddress &localAdapter = QBluetoothAddress()); // Method used for starting the server
private:
QBluetoothServer *rfcommServer; // Variable for Server-Instance
};
#include <QtCore/QObject>
#include <QtBluetooth/QBluetoothServer>
QT_FORWARD_DECLARE_CLASS(QBluetoothServer)
class BtConn : public QObject
{
Q_OBJECT
public:
explicit BtConn(QObject *parent = 0); // Constructor
void startServer(const QBluetoothAddress &localAdapter = QBluetoothAddress()); // Method used for starting the server
private:
QBluetoothServer *rfcommServer; // Variable for Server-Instance
};
To copy to clipboard, switch view to plain text mode
and the Code File btconn.cpp:
#include "btconn.h"
{
// Constructor won't do anything
}
// Start the Bluetooth Server
void BtConn::startServer(const QBluetoothAddress& localAdapter)
{
if (rfcommServer)
return;
rfcommServer = new QBluetoothServer(QBluetoothServiceInfo::RfcommProtocol, this);
}
#include "btconn.h"
BtConn::BtConn(QObject *parent) : QObject(parent)
{
// Constructor won't do anything
}
// Start the Bluetooth Server
void BtConn::startServer(const QBluetoothAddress& localAdapter)
{
if (rfcommServer)
return;
rfcommServer = new QBluetoothServer(QBluetoothServiceInfo::RfcommProtocol, this);
}
To copy to clipboard, switch view to plain text mode
I really hope that someone has an idea on how to solve that problem.
Best regards
PS: English isn't my main language - sorry for typos and grammar mistakes.
Bookmarks