I'm banging my head against a wall, this seems like it should be easy but I can't make it work.
I have several sketches that share common code, I want to put that common code into a library. In my libraries directory I created a new folder, in that folder I put a .cpp file, a .h file and a library.properties file.
In the IDE (2.3.2), I went to Sketch->Include Library and under "contributed libraries" it shows my library. When I click on it, the IDE inserts a line into my .ino file, #include <library.h>.
So far, that all looks good. But when I go to compile the sketch, I get:
fatal error: No such file or directory
I feel like there's something simple I'm missing but I'm not getting it.
Hi @dccontrarian. I'm going to ask you to post the full verbose output from a compilation.
This procedure is not intended to solve the problem. The purpose is to gather more information.
Please do this:
Select File > Preferences... (or Arduino IDE > Settings... for macOS users) from the Arduino IDE menus.
The "Preferences" dialog will open.
Check the box next to "Show verbose output during: ☐ compilation" in the "Preferences" dialog.
Click the "OK" button.
Select Sketch > Verify/Compile from the Arduino IDE menus.
Wait for the compilation to fail.
You will see a "Compilation error: ..." notification at the bottom right corner of the Arduino IDE window. Click the "COPY ERROR MESSAGES" button on that notification.
Open a forum reply here by clicking the "Reply" button.
Click the <CODE/> icon on the post composer toolbar.
This will add the forum's code block markup (```) to your reply to make sure the error messages are correctly formatted.
Press the Ctrl+V keyboard shortcut (Command+V for macOS users).
This will paste the compilation output into the code block.
Move the cursor outside of the code block markup before you add any additional text to your reply.
Click the "Reply" button to post the output.
In case the output is longer than the forum software will allow to be added to a post, you can instead save it to a .txt file and then attach that file to a reply here:
Open a forum reply here by clicking the "Reply" button.
Click the "Upload" icon () on the post composer toolbar:
The "Open" dialog will open.
Select the .txt file you saved from the "Open" dialog.
Click the "Open" button.
The dialog will close.
Click the "Reply" button to publish the post.
Alternatively, instead of using the "Upload" icon on the post composer toolbar as described in steps (5) - (7) above, you can simply drag and drop the .txt file onto the post composer field to attach it.
The include line comes from library.properties. The capitalization of the file has to match the actual file. If there is a src directory the compiler looks there first.
I had two versions of the file, one in the library directory, one in the src, the one in the library was properly capitalized but the one in src wasn't. Somehow that all confused the compiler.