QtBluetooth - Linker Problems
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:
Quote:
\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:
Code:
#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
};
and the Code File btconn.cpp:
Code:
#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);
}
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.
Re: QtBluetooth - Linker Problems
Did you make sure that the Qt you are linking against was built with BT support?
Re: QtBluetooth - Linker Problems
It should be - the QML Classes (BluetoothSocket, BluetoothAddress and BluetoothDiscoveryModel) work properly - but sadly, with QML only, I can't set up a Bluetooth Server which is needed for pairing with a slave device. For that, I need the QBluetoothServer C++ Class which seems to be faulty.
There are also code samples for Sailfish OS and Bluetooth on the web, but without the QBluetoothServer since they seem to want to pair the device with other "intelligent" devices.
Re: QtBluetooth - Linker Problems
Seems this might be a Sailfish issue.
https://together.jolla.com/question/...oth-bluetooth/
Some of the comments are from as as late as Jan 2017.
So maybe you can ask in more Saidfish/Jolla forums.
Also, have you read through this page?:
http://doc.qt.io/qt-5/qtbluetooth-in...g-qt-bluetooth
Seems support my vary...