Solved Adding Nordic pc-ble driver to Qt application
-
Hello,
I try to add the Nordic pc-ble driver to a Qt application. For this I create a simple and empty window:
VERSION_MAJOR = 1 VERSION_MINOR = 0 VERSION_BUILD = 0 QT += core gui serialport greaterThan(QT_MAJOR_VERSION, 4): QT += widgets CONFIG += c++11 file_copies COPIES += packageSetup configSetup # The following define makes your compiler emit warnings if you use # any Qt feature that has been marked 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 \ "VERSION_MAJOR=$$VERSION_MAJOR" \ "VERSION_MINOR=$$VERSION_MINOR" \ "VERSION_BUILD=$$VERSION_BUILD" \ # You can also make your code fail to compile if it uses 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 RESOURCES += \ Ressources.qrc DEPENDPATH += \ Nordic/nrf-ble-driver-4.1.4-win_x86_64/include/sd_api_v5 \ INCLUDEPATH += \ Nordic/nrf-ble-driver-4.1.4-win_x86_64/include/sd_api_v5 \ SOURCES += \ main.cpp \ mainwindow.cpp \ HEADERS += \ mainwindow.h \ FORMS += \ mainwindow.ui \ TRANSLATIONS += \ LIBS += \ -L$${PWD}/Nordic/nrf-ble-driver-4.1.4-win_x86_64/lib -lnrf-ble-driver-sd_api_v5-mt-4_1_4 \ -L$${PWD}/Nordic/nrf-ble-driver-4.1.4-win_x86_64/lib -lnrf-ble-driver-sd_api_v5-mt-static-4_1_4 \ # Target version VERSION = $${VERSION_MAJOR}.$${VERSION_MINOR}.$${VERSION_BUILD} # Set the application icon win32:RC_ICONS += # Set the build directories CONFIG(debug, debug|release) { DESTDIR = debug } else { DESTDIR = ../packages/com.daniel-kampert.DataDownloader/data } # Copy package and configuration files CONFIG(debug, debug|release) { packageSetup.path = $$shell_quote($${OUT_PWD}/debug) configSetup.path = $$shell_quote($${OUT_PWD}/debug) } else { packageSetup.path = $$shell_quote($${DESTDIR}) configSetup.path = $$shell_quote(../config) } # Deployment rules DEPLOY_COMMAND = $$(QTDIR)/bin/windeployqt DEPLOY_OPTIONS = "--no-system-d3d-compiler --no-opengl --no-angle --no-opengl-sw" DEPLOY_TARGET = $$shell_quote($$shell_path($${DESTDIR}/$${TARGET}.exe)) CONFIG(debug, debug|release) { DEPLOY_OPTIONS += "--debug" } else { DEPLOY_OPTIONS += "--release" } QMAKE_POST_LINK = $${DEPLOY_COMMAND} $${DEPLOY_OPTIONS} $${DEPLOY_TARGET}
mainwindow.cpp
#include "mainwindow.h" #include "ui_mainwindow.h" void MainWindow::StatusHandler(adapter_t * Adapter, sd_rpc_app_status_t code, const char * message) { } void MainWindow::ble_evt_dispatch(adapter_t * Adapter, ble_evt_t * p_ble_evt) { } void MainWindow::log_handler(adapter_t* adapter, sd_rpc_log_severity_t severity, const char * message) { } MainWindow::MainWindow(QWidget* parent) : QMainWindow(parent), _mUi(new Ui::MainWindow) { this->_mUi->setupUi(this); physical_layer_t * phy; phy = sd_rpc_physical_layer_create_uart("COM5", 1000000, SD_RPC_FLOW_CONTROL_NONE, SD_RPC_PARITY_NONE); } MainWindow::~MainWindow() { delete this->_mUi; }
But I can´t start (or debug) the application, because the application crashes without any specific error.
I have tried it with both Kits in Debug and Release configuration.
What is wrong here and how can I link this library to my application?
-
Hi,
Beside the point made by @jsulm, did you ensure that the .dlls can be found at run time by your application.
-
@Kampino said in Adding Nordic pc-ble driver to Qt application:
-L$${PWD}/Nordic/nrf-ble-driver-4.1.4-win_x86_64/lib -lnrf-ble-driver-sd_api_v5-mt-4_1_4
-L$${PWD}/Nordic/nrf-ble-driver-4.1.4-win_x86_64/lib -lnrf-ble-driver-sd_api_v5-mt-static-4_1_4Why do you add static and non-static libs at the same time?
Which compiler was used to build that driver lib? -
Hi,
that was a misstake. I have removed the static version:
VERSION_MAJOR = 1 VERSION_MINOR = 0 VERSION_BUILD = 0 QT += core gui serialport greaterThan(QT_MAJOR_VERSION, 4): QT += widgets CONFIG += c++11 file_copies COPIES += packageSetup configSetup # The following define makes your compiler emit warnings if you use # any Qt feature that has been marked 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 \ "VERSION_MAJOR=$$VERSION_MAJOR" \ "VERSION_MINOR=$$VERSION_MINOR" \ "VERSION_BUILD=$$VERSION_BUILD" \ # You can also make your code fail to compile if it uses 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 RESOURCES += \ Ressources.qrc DEPENDPATH += \ Nordic/nrf-ble-driver-4.1.4-win_x86_64/include/sd_api_v5 \ INCLUDEPATH += \ Nordic/nrf-ble-driver-4.1.4-win_x86_64/include/sd_api_v5 \ SOURCES += \ main.cpp \ mainwindow.cpp \ HEADERS += \ mainwindow.h \ FORMS += \ mainwindow.ui \ TRANSLATIONS += \ LIBS += \ -L$${PWD}/Nordic/nrf-ble-driver-4.1.4-win_x86_64/lib -lnrf-ble-driver-sd_api_v5-mt-4_1_4 \ # Target version VERSION = $${VERSION_MAJOR}.$${VERSION_MINOR}.$${VERSION_BUILD} # Set the application icon win32:RC_ICONS += # Set the build directories CONFIG(debug, debug|release) { DESTDIR = debug } else { DESTDIR = ../packages/com.daniel-kampert.DataDownloader/data } # Copy package and configuration files CONFIG(debug, debug|release) { packageSetup.path = $$shell_quote($${OUT_PWD}/debug) configSetup.path = $$shell_quote($${OUT_PWD}/debug) } else { packageSetup.path = $$shell_quote($${DESTDIR}) configSetup.path = $$shell_quote(../config) } #packageSetup.files += $$shell_quote(Ressources/Icons/icons8-food-96.ico) \ # $$shell_quote(Ressources/Icons/icons8-food-96.png) \ #configSetup.files += $$shell_quote(Ressources/Icons/icons8-food-96.ico) \ # $$shell_quote(Ressources/Icons/icons8-food-96.png) \ # Deployment rules DEPLOY_COMMAND = $$(QTDIR)/bin/windeployqt DEPLOY_OPTIONS = "--no-system-d3d-compiler --no-opengl --no-angle --no-opengl-sw" DEPLOY_TARGET = $$shell_quote($$shell_path($${DESTDIR}/$${TARGET}.exe)) CONFIG(debug, debug|release) { DEPLOY_OPTIONS += "--debug" } else { DEPLOY_OPTIONS += "--release" } QMAKE_POST_LINK = $${DEPLOY_COMMAND} $${DEPLOY_OPTIONS} $${DEPLOY_TARGET}
I have downloaded the prebuild version of the library from the release page (64 Bit Windows), so I don´t know which compiler was used to get the build.
-
Hi,
Beside the point made by @jsulm, did you ensure that the .dlls can be found at run time by your application.
-
Hi @SGaist,
I forgot the DLLs. It´s working now :)