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

Problems adding cJson library

Hi,

I need to use cJson library to parse some json data. I have seen that the library is located at "nrf\ext\cjson" path. I have also seen how to add that library to a project. However, I have not the option "Preprocessor" in my "options" menu. To develop my app I have modified one of the samples provided by you, so maybe the project is not correctly configured. I will upload some screenshots:

Please, can anyone tell me what do I need to do to add cJson library to my project?

Thanks.

Parents
  • Hi,

     

    To add cjson to your project, you can add CONFIG_CJSON_LIB=y to your prj.conf, then reimport the project.

    Could you try this and see if it works?

     

    Kind regards,

    Håkon

  • Hi, 

    I have edited my prj.conf to add CONFIG_CJSON_LIB=y and then included #include <cJSON.h> to my main program. When I compile the program a cJson.c file opens in Segger and I get an error saying that "math.h" file is missing.

    I have not found "math.h" file in any path... do I have to download it from Github? In that case, how do I add it to my project?

    Thanks a lot.

  • Hi,

     

    That is a standard library header, which does not seem to be implemented in the minimal libc revision that you're using.

    You'll need to switch your libc to newlibc. This can be done by adding:

    CONFIG_NEWLIB_LIBC=y

     

    Kind regards,

    Håkon

  • Hi;

    Thank you, that worked!

Reply Children
No Data