This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Building the examples in pc-ble-driver from scratch

I have just received a set of nRF52840 dongles and I want to write applications that run on the PC using the dongle so I have downlaoded the pre-compiled pc-ble-driver located here: https://github.com/NordicSemiconductor/pc-ble-driver/releases/tag/v4.1.1.

I downloaded the zip for the 64-bit version of windows. I assumed that this download would have the connectivity HEX file for the dongle, the libraries I would need to access the dongle's BLE methods, and the h-files. Then I could start a VS 2019 project, link the libraries and the h-files to the project and start writing source code. TO make life easier I get the example heart rate monitor from the pc-ble-driver project on github. It is only one file main.c

Using nRF Connect Desktop tool, I have installed the connectivity_4.1.1_usb_with_s140_6.1.1.hex file onto the dongle. That appears to be the latest version. Everything appears to be fine so far.

I was hoping that the h-files in the directory nrf-ble-driver-4.1.1-win_x86_64\include\sd_api_v6 of the pre-built project would be sufficient; but apparently not. There were several definitions that were not understood. Turns out I have to define the preprocessor variable to set the version as follows #define NRF_SD_BLE_API 6. That solved all those problems. Now the code is ready to build.

I have set the project to use static linking to the libraries assuming that this huge library file nrf-ble-driver-sd_api_v6-mt-static-4_1_1.lib would then have all I need. But build the project I get 16 undefined symbols. 

1>main.c
1>main.obj : error LNK2019: unresolved external symbol __imp_sd_ble_gap_adv_set_configure referenced in function advertisement_data_set
1>main.obj : error LNK2019: unresolved external symbol __imp_sd_ble_gap_adv_start referenced in function advertising_start
1>main.obj : error LNK2019: unresolved external symbol __imp_sd_ble_gatts_service_add referenced in function services_init
1>main.obj : error LNK2019: unresolved external symbol __imp_sd_ble_gatts_characteristic_add referenced in function characteristic_init
1>main.obj : error LNK2019: unresolved external symbol __imp_sd_ble_gatts_hvx referenced in function heart_rate_measurement_send
1>main.obj : error LNK2019: unresolved external symbol __imp_sd_ble_gatts_sys_attr_set referenced in function ble_evt_dispatch
1>main.obj : error LNK2019: unresolved external symbol __imp_sd_ble_gatts_exchange_mtu_reply referenced in function ble_evt_dispatch
1>main.obj : error LNK2019: unresolved external symbol __imp_sd_ble_enable referenced in function ble_stack_init
1>main.obj : error LNK2019: unresolved external symbol __imp_sd_ble_cfg_set referenced in function ble_cfg_set
1>main.obj : error LNK2019: unresolved external symbol __imp_sd_rpc_physical_layer_create_uart referenced in function adapter_init
1>main.obj : error LNK2019: unresolved external symbol __imp_sd_rpc_data_link_layer_create_bt_three_wire referenced in function adapter_init
1>main.obj : error LNK2019: unresolved external symbol __imp_sd_rpc_transport_layer_create referenced in function adapter_init
1>main.obj : error LNK2019: unresolved external symbol __imp_sd_rpc_adapter_create referenced in function adapter_init
1>main.obj : error LNK2019: unresolved external symbol __imp_sd_rpc_open referenced in function main
1>main.obj : error LNK2019: unresolved external symbol __imp_sd_rpc_close referenced in function main
1>main.obj : error LNK2019: unresolved external symbol __imp_sd_rpc_log_handler_severity_filter_set referenced in function main
1>E:\projects\BleTester\BleHeartRateMonitor\x64\Debug\BleHeartRateMonitor.exe : fatal error LNK1120: 16 unresolved externals

Do I need another library or is this just saying that somehow I have not set up my Visual Studio project properties to find this library (though I can't see any error in the latter). So I guess I am asking is the nrf-ble-driver-sd_api_v6-mt-static-4_1_1.lib the only library I need or am I missing a library or is the library incompatible with Visual Studio?

  • Hopefully whats in your library 'lib' is the static lib, not the dynamic. The error indictes VS is not finding your static library. If helpful, I can zip up my entire VS project/sln for you. I have started the attempt to make it secure (force pairing) which does not work yet. It is easy to remove that code since I have not gotten very far. I get another error that makes no sense but I have gotten the central to initiate pairing!

  • I checked library just in case but it is definitely nrf-ble-driver-sd_api_v6-mt-static-4_1_1.lib in source files but somehow it doesn't seem to find sd_ functions. If you could upload project/sln files, that will be much appreciated. It must be some simple setting somewhere I don't understand..

  • I can't attach files here so I will send it to you in an email

  • Turns out that it was because you used a cpp (C++) file and the example is in C. Changing the the cpp to c in the file created by the VS Console app solves the problem - for anyone else who stumbles on the same problem. (One of those things you don't think about when using the VS shell project creators).

    There is another issue that caused my library problems. Even though its a static library I linked to, if I set the project properties CodeGeneration settings to use static linking, the project will not build. I get all kinds of warning conflicts about already imported libraries by the Nordic static library which eventually become warnings. So the only way to build the project is to set the code generation to dynamic (dll) linking.

    Needless to say, I do not understand why that is so.

    But if I do, I can use the property pages to point to the Nordic static library instead of bringing it into my source or lib 'filter' folder in my project.

Related