PDA

View Full Version : QtBluetooth - Linker Problems



LaboratoryRat
6th May 2017, 14:15
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)

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
};

and the Code File btconn.cpp:


#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::RfcommProt ocol, 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.

high_flyer
7th May 2017, 20:59
Did you make sure that the Qt you are linking against was built with BT support?

LaboratoryRat
8th May 2017, 08:03
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.

high_flyer
8th May 2017, 10:22
Seems this might be a Sailfish issue.
https://together.jolla.com/question/8574/harbour-api-request-qt5-qtconnectivity-qtbluetooth-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-index.html#building-qt-bluetooth
Seems support my vary...