Hello,
I'm developing an Arduino library, but I'm having trouble including header files located in subdirectories under the src folder. If I place a file directly in src/, I can include other files from subdirectories using #include <>, but those files are not accessible from the user's sketch.
I have a library.properties file, and my directory structure is as follows (simplified for clarity):
MIDILAR
│ library.properties
│ readme.md
│
├── examples
│ ├── BuildTest
│ │ ├── BuildTest.cpp
│ │ └── CMakeLists.txt
│
├── src
│ │ MIDILAR.h
│ │ MidiProtocol.h
│ │
│ ├── AudioFoundation
│ │ ├── LUT
│ │ │ ├── BaseLUT.h
│ │ │ ├── LogExpLUT.h
│ │ │ └── SineLUT.h
│
└── tests
├── SystemFoundation
│ ├── Clock
│ │ ├── SystemFoundation_Clock.cc
library.properties :
name=MIDILAR
version=1.0.0
author=José Manuel Romo Peredo <josemanuel.romo.96@gmail.com>
maintainer=José Manuel Romo Peredo <josemanuel.romo.96@gmail.com>
sentence=A cross-platform Midi Processes library for unified development.
paragraph=CPSTL is a versatile library that provides a consistent interface for Uart Midi Ports, allowing developers to write cross-platform code that works seamlessly across different environments, with or without the C++ Standard Template Library.
category=Utilities
url=https://github.com/ChecheRomo96/MIDILAR
architectures=*
includes=
depends=
ldflags=
Issues I'm Facing:
- Header files inside
src/AudioFoundation/LUT/are not visible to the Arduino sketch. - If I move a header file to
src/, it becomes accessible. - Files within subdirectories can include each other using
#include <>, but they are not accessible from the sketch.
Questions:
- Is there a way to expose header files from subdirectories to the Arduino sketch?
- Do I need to modify the
library.propertiesfile or structure my library differently?
How I spotted this issue:
I started by creating an empty Arduino sketch and attempted to include:
#include <AudioFoundation/LUT/BaseLUT.h>
However, the compiler reported that the file could not be found. To investigate further, I replaced the include statement with:
#include <MIDILAR.h>
This successfully compiled, as MIDILAR.h includes all the relevant submodules. To further isolate the issue, I changed the include statement again to:
#include <MIDILAR_AudioFoundation.h>
This also compiled without issues. Since MIDILAR_AudioFoundation.h is inside the src subdir, and included by MIDILAR.h, this file itself includes AudioFoundation/LUT/BaseLUT.h, I concluded that only files located in the root of the src/ directory are directly visible to the sketch.
Any insights would be greatly appreciated!