ladislas / Bare-Arduino-Project

Start your Arduino projects right out of the box
MIT License
564 stars 68 forks source link

Builds fail for more complex user library structures #34

Closed sherrellbc closed 7 years ago

sherrellbc commented 7 years ago

The provided example code has a user library structure as

lib/FooLib/FooLib.h

Including this header works as expected in the current structure. However, if the intended header file name does not match the parent directory name then the build will fail with a "No such file or directory" error.

To reproduce, change the filename of lib/FooLib/FooLib.h to lib/FooLib/FooLib2.h and try to include it from FooProject.cpp. This is problematic for libraries with more than one header file.

ladislas commented 7 years ago

yes it's a known issue and is due to the way Arduino-Makefile is made. I've tried working on it but never got the results I needed.

BUT, you can overcome that by having one header with the name of the folder and then including other headers in this one.

Just like here: https://github.com/weareleka/moti/tree/dev/lib/FreeIMU

I just have to include FreeIMU.h in my main.cpp

sherrellbc commented 7 years ago

This is exactly as I did. I was hoping there would be a simpler solution. It may be simpler to just pass the include (-I) option to gcc pointing to the root user-lib directory and require the user to qualify the origin of the header in the include statement. Namely,

include <FooLib/FooLib.h>

include <CustomLib/CustomThings.h>

Just as is necessary when linking against some Linux resources (.e.g sys/stat.h, etc).

ladislas commented 7 years ago

yes that also works! 👍