Tutorial for creating multi cpp file arduino project

Seems a tad weird! A #include in a source file in src should be able to find a header file that lives in include. (Without needing to add relative paths.)

Aha!

It’s building the library, not the main.cpp file, my mistake.

Headers for libraries need to go in the library directory I have found. This keeps them self-contained. The exception to this are the compiler supplied headers.

So,

  • sensors.cpp and sensors.h are in lib/sensors
  • Any other headers specific to the library, are in the same place.
  • In the library sources, you would #include the list of required headers explicitly. (<stdint.h> and “Arduino.h”).
  • Headers for the main app file(s) go in src or include.

HTH

Cheers,
Norm.

1 Like