Build Headaches....

The build system seems to be fighting me....

I usually do my development using VisualStudio/VisualMicro, which works fine. The project builds perfectly under VS/VM. But, the current project is being done for someone else, and has to be buildable using the Arduino IDE. So, I've just take the first crack at building with the IDE, and it's not going well. All libraries are being properly copied to the build directory, but then there is no attempt to actually compile them before linking, so the link fails with a bunch of undefined symbols. I suspect the problem is related to the directory structure, which is as follows:

contains the following:

Sketch Folder QuickDrawTimer ==>
QuickDrawTimer.ino
Folder QuickDrawTimer/TMRpcm ==>
TMRpcm.h
TMRpcm.cpp
Folder QuickDrawTimer/QDIRRemote ==>
QDIRRemote.h
QDIRRemote.cpp
Folder QuickDrawTimer/QDIRRemote/IRRemote_NEC ==>
IRRemote_NEC.h
IRRemote_NEC.cpp

It's been years since I've tried to build anything but trivial sketches in the Arduino IDE, so perhaps this structure is not supported by the build system? But it seems odd that the sketch itself compiles fine, and it DOES copy the entire directory to the build directory, so everything it needs to build is there, but it never tries to build ANY of the libraries within the sketch folder.

The build log is attached.

Regards,
Ray L.

buildlog.txt (12.8 KB)

Looks like the local libraries are not #included. What #include lines do you have in QuickDrawTimer.ino?

QuickDrawTimer.ino includes:

#include <Arduino.h>
#include <EEPROM.h>
#include "SPI.h"
#include "SD.h"
#include "TMRpcm/TMRpcm.h"
#include "QDIRRemote/IRRemote_NEC/IRRemote_NEC.h"
#include "QDIRRemote/QDIRRemote.h"

IRRemote_NEC.cpp includes:

#include "IRRemote_NEC.h"

IRRemote_NEC.h includes:

#include <Arduino.h>

QDIRRemote.cpp includes:

#include "QDIRRemote.h"

QDIRRemote.h includes

#include <Arduino.h>
#include <EEPROM.h>
#include "IRRemote_NEC/IRRemote_NEC.h"

TMRpcm.cpp includes:

#include "TMRpcm.h"

The include paths are all correct, as it compiles correctly in VS./VM.

Regards,
Ray L.

I seem to have found the answer:

Put all sketch libraries in a "src" sub-folder of the sketch folder. This is one of the places the IDE searches for #includes, since about v1.5.

I can now compile with the IDE, with no problems.

Regards,
Ray L.

Well, this build process is really bizarre....

The structure I ended up with is basically what I started with but with the TMRpcm and QDIRRremote folders under a src folder of the sketch folder. I then had to edit the #includes in all the files below this new src directory to be relative paths from each file to the file being included..

Why on earth doesn't it simply treat the src directory as another libraries directory, and search it for all includes? Seems really goofy.

But, I now have structure that works for both VS/VM and the Arduino IDE, even though some of the include paths are goofy...

Regards,
Ray L.

Which group(s) of files are meant to be libraries?

[quote author=Coding Badly date=1509734172 link=msg=3472452]
Which group(s) of files are meant to be libraries?[/quote]
Each of the folders under src/. i.e.: TMRpcm, QDIRRemote, IRRemote_NEC
Regards,
Ray L.

Assuming I understand, they are NOT in the libraries folder. Is that correct?

[quote author=Coding Badly date=1509735689 link=msg=3472491]
Assuming I understand, they are NOT in the libraries folder. Is that correct?[/quote]
Correct. They are in the "src" subdirectory of the sketchbook directory. These are libraries used ONLY for this one sketch, putting them in the libraries folder would not make sense. I need the entire sketch, and its libraries, to be self-contained, so it can be easily handed off to someone else in a single ZIP file, without requiring them to install libraries somewhere else.
Regards,
Ray L.

Got it.

I wasn't aware that the IDE would handle subdirectories in the user sketch at all. The current handling of src/ sounds like it might be something inherited from the library (directory) handling code (perhaps unintentionally and partially broken?)

Requiring the libraries to be located under the src folder is the intentional behavior. When support for sketch subfolders was first added it did not have this restriction and it caused some sketches to break because people had previously put things in subfolders of the sketch folder that they had no intention of being compiled.

See:

and