Azure-Samples / iot-hub-c-raspberrypi-client-app

Application collects weather data from a BME280 sensor and sends it to IoT hub, also take actions according to cloud-to-device message, device management.
https://docs.microsoft.com/en-us/azure/iot-hub/iot-hub-raspberry-pi-kit-c-get-started
MIT License
36 stars 34 forks source link

Error: App does not get created with current git master in azure-iothub-c-sdk (JSON problem?) #25

Closed handcyclist closed 6 years ago

handcyclist commented 6 years ago

The app cannot be created with the current azure-iothub-c-sdk master in git. The app does get created with lts_01_2018 and lts_07_2017 The attached files shows the error produced

Error-JSON-AzureRaspberryExample.txt

SLdragon commented 6 years ago

It seems like that the changes of latest sdk break our demo. Please use the stable release branch instead.

From your error log, seems your system do not have this library: https://github.com/kgabis/parson You can try to install it and try again.

You can also give us more detailed information about you raspberry pi, such as raspberry pi hardware version and system version, so that we can try to reproduce it.

Thanks

handcyclist commented 6 years ago

It worked with parson. I had no clue as to what to do because I do not yet understand cmake/make nor linking. The parson instruction only said to "copy parson.h and parson.c to you source code tree", and I did not know exactly what that meant. But anyway, I was able to make it work.

The app was able to compile with the latest master of the azure-iothub-c-sdk by including the json library from the parson code. I copied the files parson.c and parson.h to directory iot-hub-c-raspberrypi-client-app. I modified a line of code in CMakeLists.txt file to include parson.c and parson.h <set(SOURCE main.c bme280.c wiring.c telemetry.c parson.c config.h bme280.h wiring.h telemetry.h parson.h)>

Before addin parson, the app installation had also failed even after I had tried to update the JSON library by updating node. It failed even with node version 9.8.0 that got updated from 4.8.2 after I removed nodered and installed "n" per https://stackoverflow.com/questions/42741243/how-do-you-install-newest-version-of-node-js-on-raspberry-pi#42741265

I have a Raspberry Pi 3 that I bought back 2 months ago in January 2018 and it's loaded with the recommended Raspbian OS on a 8Gb sdcard.

The attached file has information on my system RPiInfo.txt

Thank you for your help

SLdragon commented 6 years ago

Hi, @handcyclist, you are right, you need to copy the source code to the directory "iot-hub-c-raspberrypi-client-app" and then modify the CMakeList.txt file to include parson.c and parson.h. This would make the compile success.

However, you do not need to update node and install node version of parson, they are totally different libraries.

This issue is related to the C SDK: https://github.com/Azure/azure-iot-sdk-c/issues/429

We will wait for the latest stable release of the C SDK, if the problem remain exists, then we will update our sample code to fix the issue.

Thanks

SLdragon commented 6 years ago

The lastest sdk solved the problem, so close this issue.

hamburml commented 5 years ago

@SLdragon I have installed Raspbian and upgraded today, tried to build this example client and got the same error. Were there new sdk changes?

[ 20%] Building C object CMakeFiles/app.dir/main.c.o
[ 40%] Building C object CMakeFiles/app.dir/wiring.c.o
[ 60%] Linking C executable app
//usr/local/lib/libiothub_client.a(iothub_client_ll_uploadtoblob.c.o): In function `IoTHubClient_LL_UploadToBlob_step1and2':
iothub_client_ll_uploadtoblob.c:(.text+0x1018): undefined reference to `json_parse_string'
iothub_client_ll_uploadtoblob.c:(.text+0x1084): undefined reference to `json_value_get_object'
iothub_client_ll_uploadtoblob.c:(.text+0x10fc): undefined reference to `json_object_get_string'
iothub_client_ll_uploadtoblob.c:(.text+0x11e0): undefined reference to `json_object_get_string'
iothub_client_ll_uploadtoblob.c:(.text+0x1258): undefined reference to `json_object_get_string'
iothub_client_ll_uploadtoblob.c:(.text+0x12d0): undefined reference to `json_object_get_string'
iothub_client_ll_uploadtoblob.c:(.text+0x1348): undefined reference to `json_object_get_string'
iothub_client_ll_uploadtoblob.c:(.text+0x1814): undefined reference to `json_value_free'
collect2: error: ld returned 1 exit status
CMakeFiles/app.dir/build.make:172: die Regel für Ziel „app“ scheiterte
make[2]: *** [app] Fehler 1
CMakeFiles/Makefile2:67: die Regel für Ziel „CMakeFiles/app.dir/all“ scheiterte
make[1]: *** [CMakeFiles/app.dir/all] Fehler 2
Makefile:83: die Regel für Ziel „all“ scheiterte
make: *** [all] Fehler 2

Is it really the solution to manually copy some files inside the project?

Alberto-Vega commented 5 years ago

Four more users reporting this issue xsqian aepsicom inesk-vt kuriancjohn Moving these two issues here https://github.com/MicrosoftDocs/azure-docs/issues/18981
https://github.com/MicrosoftDocs/azure-docs/issues/24308