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

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

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

跳至解决方案
9,532 次查看
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 项奖励
回复
1 解答
9,472 次查看
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 项奖励
回复
11 回复数
9,473 次查看
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 项奖励
回复
9,526 次查看
converse
Senior Contributor V

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

0 项奖励
回复
9,512 次查看
mazimcoder
Contributor II

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

0 项奖励
回复
9,504 次查看
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 项奖励
回复
9,498 次查看
mazimcoder
Contributor II

still nothing!

mazimcoder_1-1625079845905.png

mazimcoder_2-1625079911178.png

 

 

 

 

0 项奖励
回复
9,493 次查看
converse
Senior Contributor V

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

0 项奖励
回复
9,492 次查看
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 项奖励
回复
9,491 次查看
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 项奖励
回复
9,488 次查看
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 项奖励
回复
9,487 次查看
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 项奖励
回复
9,485 次查看
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 项奖励
回复