Multiple Source/Header Files and Linker Errors Using ESP-IDF

I am trying to use multiple source and header files, but building fails. Since I am targeting an ESP-IDF framework, I have included appropriate minimal source, header and configuration files.

My PlatformIO Core: 4.3.2a1, Home: 3.1.1, using VS Code.

It is my hope that someone can make the required changes to the configuration files, header and source files (#include statements or whatever else) to allow building in two scenarios:

Scenario 1. Multiple c/c++ files in the project src directory and header files the appropriate directory.
Scenario 2. Add c/c++ and header files in the project lib directory.

Here are the source and header files:


#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "esp_system.h"

#include <AnotherFile.h>
//#include "..\lib\AnotherFile.h"
void app_main()
        printf("Hello World %d\n", iTake5()); // iTake5() in AnotherFile.cpp
        vTaskDelay(500 / portTICK_RATE_MS);


#ifndef _ANOTHER_FILE_H_
    #define _ANOTHER_FILE_H_
    int iTake5(void);
#endif // _ANOTHER_FILE_H_


#include <AnotherFile.h>
//#include "AnotherFile.h"

int iTake5(void)
    return 5;

platformio.ini (the first two lines seem unnecessary because they are the default locations, so they are commented out):

;include_dir = "Crap003\include"
;lib_dir = "Crap003\lib"

platform = espressif32
board = esp-wrover-kit
framework = espidf
build_type = debug
;build_type = release
monitor_speed = 115200
debug_tool = esp-prog
debug_init_break = tbreak setup



idf_component_register(SRCS ${app_sources})

Scenario 1. Expected that Main.c and AnotherFile.cpp would be in src, with AnotherFile.h in include (or src?). #include statements use <>, as seen in an example - if quotes are required, please set as required. Please list any changes made to any files!

Scenario 2. Expected that Main.c would go to src. AnotherFile.h and AnotherFile.cpp in lib. It would seem that AnotherFile.cpp wouldn’t be listed in CMakeLists.txt.
#include statements use <> - if quotes are required, please set as required. Please list any changes made to any files!

As a bonus, if it is desired to have multiple subdirectories within lib (e.g. Foo and Bar), could <> still be used for #include statements, with changes to platformio.ini (and what would those changes be)? If quotes are required, please indicate a correct #include in Main.c.

I would like to create a small set of simple examples with these results, in addition to a few RTOS concepts for those new to this environment, like me! Done by moderation

Many thanks in advance.

P.S. Sorry about the code formatting. How do I include a code sample so it formats properly?

Solved for the first scenario - files in the src directory:
All c/cpp/h files are in the src directory.
#includes use <> rather than quotes, as shown.
Platformio.ini as shown. The commented lines can be removed.
CMakeLists.txt has “AnotherFile.h” line added, which was the problem all along.

Not sure why some text has the strike through from the moderator.