Hi, I have the following directory structure.
I can include files from /utils/segger_rtt/RTT no problem but I cannot find out how to add the source files to the compiler
I have tried to use the /lib directory, but it doesn’t work either, platformio doesn’t recognize files inside there. Also, I want to use my own project structure.
See the attached screenshot for more detail
Please let me know how to do this
All to-be-compiled files must be under src/ or in a library under lib/. The position of your utils folder is simply wrong.
Also, in your build_flags, don’t use absolute paths. These paths can be relative with respect to the project folder. lib_extra_dirs is used wrongly in your project, since this is not a library.
You might have additional problems with C/C++ linkage of your code. If you want to call a function from any of these C files, make sure there is an extern "C" declaration in the header surrounding the function declarations.
That might have side effects you are unaware of, I would not do that. Especiallly the rest of the C files might have problems now calling into C++ code.
(remove the _IAR and _KEIL files, they are ment for another compiler).
In your main.cpp file just do
extern "C" {
#include <SEGGER_RTT.h>
}
If PIO doesn’t automatically recognize that the library is to be used, add a lib_deps = segger_rtt line in the platformio.ini. WIth this structure, no extra ´-I` flags are needed also.