Unable to link ESP-IDF component that includes static .a files (esp_audio_codec)

I’m trying to include esp_audio_codec in my project. This comes with pre-compiled .a libraries for different esp32 variants (s2, c3, s3, etc.) The instructions in the documentation regarding ESP-IDF components seem vague to me. Here is what I tried:

  1. Create a components/ directory at the top level and then extract espressif_audio_codec_1.0.1/ there. This completely fails. The header files can’t even be picked up in my main.cpp.

  2. Move espressif_audio_codec_1.0.1/ into libs/. Now the header files are picked up but I’m getting linker errors because espressif_audio_codec_1.0.1/lib/esp32s3/libesp_audio_codec.a is not getting linked.

I searched the forum and saw someone modifying platformio.ini andadding build_flags.I tried the following (and it does work!) but it seems pretty ghetto:

build_flags = -L${PROJECT_DIR}/lib/espressif_esp_audio_codec_1.0.1/lib/esp32s3 -lesp_audio_codec

Note that I still have to manually list the target (esp32s3) here. PlatformIO really can’t pick up the library file by analyzing the contents of the package?

What is the right way to do this?


– B.