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:
Code: Select all
idf_component_register(
SRCS "sgtl5k.c"
INCLUDE_DIRS "."
)
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:
Code: Select all
#include "../components/sgtl5k/sgtl5k.h"
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