Hello,
I am using ESPIDFv4.0 and would like to include cJSON. None of the following work:
#include <cJSON/cJSON.h>
#include <cJSON.h>
#include <json/cJSON/cJSON.h>
What do I need to use in order to use cJSON in my code?
How to include cJSON?
-
- Posts: 74
- Joined: Wed Oct 23, 2019 1:49 am
Re: How to include cJSON?
#include <cJSON.h> should work. Remember to also include
in your CMakeList.txt if you are trying to use it outside your main component.
Code: Select all
REQUIRES json
Re: How to include cJSON?
Thank you, yes have a few of my own components that are needing cJSON. Your suggestions worked.
For anyone else needing assistance, here's the contents of the cv_server CMakeLists.txt, noting the addition of requiring json.
Here's the abbreviated folder structure. I bolded the files that are changed to use json.
ryan@ryan-Precision-5820-Tower:~/Development/personal/cv/clearview_interface_public/src/cvesp32$ tree -L 4
.
├── CMakeLists.txt
├── components
│ ├── cv_server
│ │ ├── CMakeLists.txt
│ │ ├── cv_server.c
│ │ ├── include
│ │ │ └── cv_server.h
│ │ └── WebsiteFiles
│ │ ├── menuBar.html
│ │ ├── settings.html
├── main
│ ├── CMakeLists.txt
│ ├── Kconfig.projbuild
│ └── main.c
├── sdkconfig
├── sdkconfig.defaults
└── version.txt
I was under the impression that any of the components in ESPIDF did not need to be required, but I was wrong.
Thanks!
For anyone else needing assistance, here's the contents of the cv_server CMakeLists.txt, noting the addition of requiring json.
Code: Select all
idf_component_register(SRCS "cv_server.c"
INCLUDE_DIRS "include"
REQUIRES esp_http_server cv_mqtt cv_ota json
EMBED_TXTFILES
WebsiteFiles/settings.html
WebsiteFiles/httpDocBegin.html
WebsiteFiles/httpDocConclude.html
WebsiteFiles/subtitle.html
WebsiteFiles/title.html
WebsiteFiles/wifiSettings.html
WebsiteFiles/test.html
WebsiteFiles/menuBar.html
WebsiteFiles/menuBarTest.html
)
ryan@ryan-Precision-5820-Tower:~/Development/personal/cv/clearview_interface_public/src/cvesp32$ tree -L 4
.
├── CMakeLists.txt
├── components
│ ├── cv_server
│ │ ├── CMakeLists.txt
│ │ ├── cv_server.c
│ │ ├── include
│ │ │ └── cv_server.h
│ │ └── WebsiteFiles
│ │ ├── menuBar.html
│ │ ├── settings.html
├── main
│ ├── CMakeLists.txt
│ ├── Kconfig.projbuild
│ └── main.c
├── sdkconfig
├── sdkconfig.defaults
└── version.txt
I was under the impression that any of the components in ESPIDF did not need to be required, but I was wrong.
Thanks!
Re: How to include cJSON?
For IDF 4.3.1 i had to add
set(REQUIRES json)
to CMakeLists.txt of my library
I thought it was working but it didn't finish building
this is the correct way
set(REQUIRES json)
to CMakeLists.txt of my library
I thought it was working but it didn't finish building
this is the correct way
Code: Select all
set(COMPONENT_REQUIRES "json")
Who is online
Users browsing this forum: No registered users and 426 guests