unable to reference to cJSON.h or json-c.h libraries despite having their paths included in C/C++

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

unable to reference to cJSON.h or json-c.h libraries despite having their paths included in C/C++

Jump to solution
9,519 Views
mazimcoder
Contributor II

paths are included as below in both compiler MCU C and MCU C++, both libraries work fine in cmake as stand-alone projects but not in MCUxpresso even after adding the paths as shown in the screenshots.

mazimcoder_0-1624993760994.png

mazimcoder_4-1624994477300.png

mazimcoder_3-1624994459741.png

 

mazimcoder_1-1624993879185.png

mazimcoder_2-1624993996177.png

the undefined reference error is applicable and occurs to all functions in which called from either of the two cJSON.h or or json.h but never on cmake since it knows where to go! Really frustrating with latest NXP SDK's API where they removed the cJSON api which was even a replica to the repository and didn't include instructions to integrate this stubborn IDE!

0 Kudos
Reply
1 Solution
9,459 Views
mazimcoder
Contributor II

I had merged the library with my project, it took quite some time since files weren't coded for ARM GCC compiler. I hope that the next NXP's SDK release would include Cjson or json-c natively to avoid such a dramatic additional work. I am not sure why would NXP refrain adding either of the two libraries, but they really have to since almost all modern applications deploy json files. I couldn't find a way to inform NXP to add those utterly valuable libraries in their SDK, but if someone does, it would be quite helpful for all NXP ARM developers

View solution in original post

0 Kudos
Reply
11 Replies
9,460 Views
mazimcoder
Contributor II

I had merged the library with my project, it took quite some time since files weren't coded for ARM GCC compiler. I hope that the next NXP's SDK release would include Cjson or json-c natively to avoid such a dramatic additional work. I am not sure why would NXP refrain adding either of the two libraries, but they really have to since almost all modern applications deploy json files. I couldn't find a way to inform NXP to add those utterly valuable libraries in their SDK, but if someone does, it would be quite helpful for all NXP ARM developers

0 Kudos
Reply
9,513 Views
converse
Senior Contributor V

Undefined reference is a *linker* error. You have not added the json library to the linker.

0 Kudos
Reply
9,499 Views
mazimcoder
Contributor II

paths are already added in the linker, yet the problem prolongs

0 Kudos
Reply
9,491 Views
converse
Senior Contributor V

Have you added the cjson library to the linker? Snapshot the linker libraries page, and post it.

note. If the library is called libcJson.a you just add cJson to the linker (it will automatically add lib to the front and .a to the end)

0 Kudos
Reply
9,485 Views
mazimcoder
Contributor II

still nothing!

mazimcoder_1-1625079845905.png

mazimcoder_2-1625079911178.png

 

 

 

 

0 Kudos
Reply
9,480 Views
converse
Senior Contributor V

Remove the first three letters “lib” from the name of the library. See my earlier comment

0 Kudos
Reply
9,479 Views
mazimcoder
Contributor II

persisting to never work out!  (with/without lib or .a) even after cleaning and re-building the project

 

mazimcoder_0-1625080449693.png

 

mazimcoder_1-1625080297205.png

 

0 Kudos
Reply
9,478 Views
mazimcoder
Contributor II

it works at this path now but I got a brand new absurd error! Apparently, the .so file isn't recognized 

mazimcoder_1-1625080758611.png

 

mazimcoder_2-1625080861118.png

 

 

 

0 Kudos
Reply
9,475 Views
converse
Senior Contributor V

Where did you get this library? .so file is a Linux shared object library, which is not compatible with embedded devices. You will need to find a version of this library built for ARM Cortex embedded applications.

0 Kudos
Reply
9,474 Views
mazimcoder
Contributor II

unfortunately, most of C/c++ based library are GCC for x86/64 and not ARM, I got it from here;

https://github.com/json-c/

 

if you know one that works with ARM, please share it!

0 Kudos
Reply
9,472 Views
converse
Senior Contributor V

Well, you are not going to get a Linux x86 library linking with anything for Cortex. But the site you pointed at provides source code, so you can just download the source code and build it yourself - but it may need some porting. For example if it is designed for Linux, it may use Linux system services, that will not be available on your target device.

0 Kudos
Reply