Trying to make component folder work
Trying to make component folder work
I have an external component folder called iot_device_common_files in the same parent folder as my project's folder iot_device
which includes .h and .cpp files.
In my project I have in Makefile:
EXTRA_COMPONENT_DIRS += $(IOT_DEVICE_COMMON_FILES_PATH)
So I have #include like this:
#include "../../iot_device_common_files/defs.h"
This works because the relative path goes from iot_device/main two levels up and into the common folder and refers to defs.h.
My next step is to include components the proper way. I want to include some FTDI USB-UART support so I created under the common folder. I'm mimicking what esp_https_client component is doing to set up some files. Just trying to log my progress here for now and I'm sure I'll encounter errors and need some help
Hope this thread when complete will help other set up their component folders
which includes .h and .cpp files.
In my project I have in Makefile:
EXTRA_COMPONENT_DIRS += $(IOT_DEVICE_COMMON_FILES_PATH)
So I have #include like this:
#include "../../iot_device_common_files/defs.h"
This works because the relative path goes from iot_device/main two levels up and into the common folder and refers to defs.h.
My next step is to include components the proper way. I want to include some FTDI USB-UART support so I created under the common folder. I'm mimicking what esp_https_client component is doing to set up some files. Just trying to log my progress here for now and I'm sure I'll encounter errors and need some help
Hope this thread when complete will help other set up their component folders
Re: Trying to make component folder work
Hi zliudr,
be sure to check the documentation on the build system, mainly the example project to get to know how the components work in the build system.
Jan
be sure to check the documentation on the build system, mainly the example project to get to know how the components work in the build system.
Jan
-
- Posts: 3
- Joined: Mon Jan 04, 2021 4:45 pm
Re: Trying to make component folder work
Hi everyone,
this is exactly what I'm having trouble with, so I'll post this here:
For context: I'm working on a project that includes the SGTL5000. I'll have to communicate with that chip via i2c, which is why I'm writing some functions that I would like to be able to easily use in other projects as well.
What I've got so far:
- working esp-idf-setup (v4.2/stable)
- project-folder with the standard (minimal) CMakelist.txt
- "components"-folder inside the project-folder, containing one subdirectory: "sgtl5k"
- inside "sgtl5k"-subdirectory: sgtl5k.h, sgtl5k.c, CMakelist.txt
Here's the CMakelist from the sgtl5k-subdirectory:
The CMakelist.txt inside the main directory is also the untouched version from the template.
I have read through the documentation zliudr posted several times now and I can't seem to find (or understand) some crucial information:
- I still have to include sgtl5k.h like this in my main.c:
From what I understand, shouldn't be enough? that's not a huge problem though, just shows me I'm misunderstanding something (which might lead to the actual problem).
- When I'm running idf.py build, I get the error "undefined reference to sgtwrite" in main.c, sgtwrite being a function from my sgtl5k-library.
I'd very much appreciate the help here since I've been reading the docs so many times now and I still can't seem to find the mistake I'm making. Any changes I've tried making to the CMakelist.txts so far felt like complete stabs in the dark, so please understand that I'll refrain from posting what I tried there to no avail.
Cheers
this is exactly what I'm having trouble with, so I'll post this here:
For context: I'm working on a project that includes the SGTL5000. I'll have to communicate with that chip via i2c, which is why I'm writing some functions that I would like to be able to easily use in other projects as well.
What I've got so far:
- working esp-idf-setup (v4.2/stable)
- project-folder with the standard (minimal) CMakelist.txt
- "components"-folder inside the project-folder, containing one subdirectory: "sgtl5k"
- inside "sgtl5k"-subdirectory: sgtl5k.h, sgtl5k.c, CMakelist.txt
Here's the CMakelist from the sgtl5k-subdirectory:
Code: Select all
idf_component_register(
SRCS "sgtl5k.c"
INCLUDE_DIRS "."
)
I have read through the documentation zliudr posted several times now and I can't seem to find (or understand) some crucial information:
- I still have to include sgtl5k.h like this in my main.c:
Code: Select all
#include "../components/sgtl5k/sgtl5k.h"
Code: Select all
#include "sgtl5k/sgtl5k.h"
- When I'm running idf.py build, I get the error "undefined reference to sgtwrite" in main.c, sgtwrite being a function from my sgtl5k-library.
I'd very much appreciate the help here since I've been reading the docs so many times now and I still can't seem to find the mistake I'm making. Any changes I've tried making to the CMakelist.txts so far felt like complete stabs in the dark, so please understand that I'll refrain from posting what I tried there to no avail.
Cheers
Re: Trying to make component folder work
Should only need this:
Try adding sgtl5k to REQUIRES in project-folder/main/CMakeLists.txt
Code: Select all
#include "sgtl5k.h"
-
- Posts: 3
- Joined: Mon Jan 04, 2021 4:45 pm
Re: Trying to make component folder work
Ok, changed the include and modified CMakelist.txt in main:
Now I get:
Code: Select all
# Edit following two lines to set component requirements (see docs)
set(COMPONENT_REQUIRES "sgtl5k" )
set(COMPONENT_PRIV_REQUIRES )
set(COMPONENT_SRCS "main.c")
set(COMPONENT_ADD_INCLUDEDIRS "")
register_component()
Code: Select all
Failed to resolve component 'sgtl5k'.
Re: Trying to make component folder work
Check these files are exactly "CMakeLists.txt"
-
- Posts: 9723
- Joined: Thu Nov 26, 2015 4:08 am
-
- Posts: 3
- Joined: Mon Jan 04, 2021 4:45 pm
Re: Trying to make component folder work
Thank you so much! The s in the end wasn't missing anywhere, but the L wasn't capitalized for sgtl5k. Now the compiler is finally complaining about my disastrous first-draft-functions in sgtl5k.c But that I can handle. I never would have noticed this after going over everything so many times. Appreciate the help!
Who is online
Users browsing this forum: No registered users and 333 guests