I have a problem that may not be solvable based on the way the Arduino IDE is made, but I want to double-check here. I have searched all over the place and so far haven't come up with anything, but I have a suspicion based on my own testing.
Here's the situation: I have a class library with a bunch of source files that are stored in subdirectories like so:
/ADXL345/ADXL345.cpp
/ADXL345/ADXL345.h
/MPU6050/MPU6050.cpp
/MPU6050/MPU6050.h
/AK8975/AK8975.cpp
/AK8975/AK8975.h
...and so on. What I want to do is create a demo file for each of these classes, something like so:
/ADXL345/ADXL345.cpp
/ADXL345/ADXL345.h
/ADXL345/ADXL345.ino
/MPU6050/MPU6050.cpp
/MPU6050/MPU6050.h
/MPU6050/MPU6050.ino
/AK8975/AK8975.cpp
/AK8975/AK8975.h
/AK8975/AK8975.ino
I'm using Arduino RC1, hence the .ino extension. I think the same problem I'm having applies in v0022 with .pde as well. Anyway, what's happening is that it appears the "MPU6050.cpp" file (for instance) is causing the entire contents of the "MPU6050.ino" file to be ignored. I get the following error when I try to compile:
core.a(main.cpp.o): In function `main':
C:\arduino-1.0-rc1\hardware\arduino\cores\arduino/main.cpp:12: undefined reference to `setup'
C:\arduino-1.0-rc1\hardware\arduino\cores\arduino/main.cpp:15: undefined reference to `loop'
Those functions are definitely present in the .ino file, but the're invisible for some reason. However, if I add the following lines to the "MPU6050.cpp" file:
void setup() { }
void loop() { }
Everything compiles just fine. It doesn't do what it's supposed to when it runs, obviously, but it does compile. So here's my theory: you can't have a sketch file with the same name (without the .ino extension) as another .cpp source file within the sketch. Is this true? If so, can it be fixed? If not, is there a way to do what I'm trying to do that does not involve changing the parent folder names so that the folder name and sketch filename don't overlap with the class source filenames? I could do something like this:
/MPU6050_lib/MPU6050.cpp
/MPU6050_lib/MPU6050.h
/MPU6050_lib/MPU6050_lib.ino
...but I'd rather not if I can avoid it. It seems like a really lame solution to a similarly lame problem, and there are at least a few links to these source files on Github that point to the non-modified folders.
Any thoughts are welcome!
Jeff