[help]libraries in subfolder

Hello
I'm writing a complex code, with many own class/libraries.
For example, in the project ~/sketchbook/Test
there are the files
Test.pde
Lib1.cpp
Lib1.h

if in Test.pde I do:

#include "Libreria1.h"

everything id ok

but if i move Lib.cpp and Lib1.h in one subfolder, like "lib" (path: ~/sketchbook/Test/lib), i write:

#include "lib/Libreria1.h"

I've got error:

Test.cpp:4:43: fatal error: lib/Libreria1.h: No such file or directory
compilation terminated.

The arduino IDE don't seem to pay attention to the subfolder! this is a big problem in complex project, someone know how to solve this? (without using external IDE?)

You need to put all your own made libraries in ~/sketchbook/

See - Libraries - Arduino Reference

If you want to keep maximum separation, you might consider to create a separate account on your PC for this project, creating an unique sketchbook folder for your complex project. With such a separate account it is also easier to keep your project documentation separated from all others.

Drawback is that reuse of libraries is a bit more work

Hopes this helps.

Just curious, how complex is your project? what do you want to make/create? There are many existing libraries out there that could ease the job!

hi, that worked!
really i've tryed this yesterday, but was too late and i miss the results! :grin:

The project is complex because it's for a quadrirotor, so I'm building an object oriented sensor system(and angle estimation algorithm), and piloting system (it will be nice to drive some rc plane). Sure there are others project but this is for "self test"

Sorry, still not working... it does only if you don't nest another folder =(

For example:
in ~/libraries there is the folder: "LibreriaA"
that contains:
Classe.cpp
Classe.h
folder "sottoclassi"
witch contains:
Sottoclasse.h
Sottoclasse.cpp

Sottoclasse has only one public method update:
Sottoclasse.h

#ifndef Sottoclasse_h
#define Sottoclasse_h

class Sottoclasse{
  public:
    void update();
  private:
  
};
#endif

Sottoclasse.cpp

#inlude "Sottoclasse.h"

void Sottoclasse::update(){
}

Classe has a variable Sottoclasse and an update method that call the update on Sottoclasse
Classe.h

#ifndef Classe_h
#define Classe_h
#import "sottoclassi/Sottoclasse.h"

class Classe{
  public:
    void update();
  private:
    Sottoclasse temp;
};
#endif

Classe.cpp

#import "Classe.h"

void Classe::update(){
  temp.update();
}

Now, in in my .pde i declare Classe:

#include <Classe.h>

Classe tmp;
void setup(){
}

void loop(){
}

everything run fine

but if I try to use update()...

#include <Classe.h>

Classe tmp;
void setup(){
  tmp.update();
}

void loop(){
}

I've got a compilation error:

LibreriaA/Classe.cpp.o: In function Classe::update()': ~/sketchbook/libraries/LibreriaA/Classe.cpp:4: undefined reference to Sottoclasse::update()'
collect2: ld returned 1 exit status

include sottoclasse does not do the trick:

#include <sottoclassi/Sottoclasse.h>

same error.

I've also tryed to inizialize the classes, with a constructor in Classe.cpp (and it's declaration in Classe.h)

Classe::Classe(){
  temp = Sottoclasse();
}

and in the .pde:

#include <Classe.h>
#include <sottoclassi/Sottoclasse.h>
Classe tm;
void setup(){
  tmp = Classe();
  tmp.update();
}

void loop(){
}

compilation output:

avr-g++ -c -g -Os -w -fno-exceptions -ffunction-sections -fdata-sections -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=22 -I~/hardware/arduino/cores/arduino -I~/sketchbook/libraries/LibreriaA /tmp/build3895633309484179111.tmp/sketch_apr28a.cpp -o/tmp/build3895633309484179111.tmp/sketch_apr28a.cpp.o
avr-g++ -c -g -Os -w -fno-exceptions -ffunction-sections -fdata-sections -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=22 -I~/arduino-0022/hardware/arduino/cores/arduino -I~/sketchbook/libraries/LibreriaA -I~/sketchbook/libraries/LibreriaA/utility ~/sketchbook/libraries/LibreriaA/Classe.cpp -o/tmp/build3895633309484179111.tmp/LibreriaA/Classe.cpp.o
avr-gcc -c -g -Os -w -ffunction-sections -fdata-sections -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=22 -I~/arduino-0022/hardware/arduino/cores/arduino ~/arduino-0022/hardware/arduino/cores/arduino/wiring_shift.c -o/tmp/build3895633309484179111.tmp/wiring_shift.c.o
avr-gcc -c -g -Os -w -ffunction-sections -fdata-sections -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=22 -I~/arduino-0022/hardware/arduino/cores/arduino ~/arduino-0022/hardware/arduino/cores/arduino/wiring_digital.c -o/tmp/build3895633309484179111.tmp/wiring_digital.c.o
avr-gcc -c -g -Os -w -ffunction-sections -fdata-sections -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=22 -I~/arduino-0022/hardware/arduino/cores/arduino ~/arduino-0022/hardware/arduino/cores/arduino/wiring.c -o/tmp/build3895633309484179111.tmp/wiring.c.o
avr-gcc -c -g -Os -w -ffunction-sections -fdata-sections -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=22 -I~/arduino-0022/hardware/arduino/cores/arduino ~/arduino-0022/hardware/arduino/cores/arduino/wiring_analog.c -o/tmp/build3895633309484179111.tmp/wiring_analog.c.o
avr-gcc -c -g -Os -w -ffunction-sections -fdata-sections -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=22 -I~/arduino-0022/hardware/arduino/cores/arduino ~/arduino-0022/hardware/arduino/cores/arduino/pins_arduino.c -o/tmp/build3895633309484179111.tmp/pins_arduino.c.o
avr-gcc -c -g -Os -w -ffunction-sections -fdata-sections -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=22 -I~/arduino-0022/hardware/arduino/cores/arduino ~/arduino-0022/hardware/arduino/cores/arduino/wiring_pulse.c -o/tmp/build3895633309484179111.tmp/wiring_pulse.c.o
avr-gcc -c -g -Os -w -ffunction-sections -fdata-sections -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=22 -I~/arduino-0022/hardware/arduino/cores/arduino ~/arduino-0022/hardware/arduino/cores/arduino/WInterrupts.c -o/tmp/build3895633309484179111.tmp/WInterrupts.c.o
avr-g++ -c -g -Os -w -fno-exceptions -ffunction-sections -fdata-sections -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=22 -I~/arduino-0022/hardware/arduino/cores/arduino ~/arduino-0022/hardware/arduino/cores/arduino/Tone.cpp -o/tmp/build3895633309484179111.tmp/Tone.cpp.o
avr-g++ -c -g -Os -w -fno-exceptions -ffunction-sections -fdata-sections -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=22 -I~/arduino-0022/hardware/arduino/cores/arduino ~/arduino-0022/hardware/arduino/cores/arduino/WMath.cpp -o/tmp/build3895633309484179111.tmp/WMath.cpp.o
avr-g++ -c -g -Os -w -fno-exceptions -ffunction-sections -fdata-sections -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=22 -I~/arduino-0022/hardware/arduino/cores/arduino ~/arduino-0022/hardware/arduino/cores/arduino/WString.cpp -o/tmp/build3895633309484179111.tmp/WString.cpp.o
avr-g++ -c -g -Os -w -fno-exceptions -ffunction-sections -fdata-sections -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=22 -I~/arduino-0022/hardware/arduino/cores/arduino ~/arduino-0022/hardware/arduino/cores/arduino/Print.cpp -o/tmp/build3895633309484179111.tmp/Print.cpp.o
avr-g++ -c -g -Os -w -fno-exceptions -ffunction-sections -fdata-sections -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=22 -I~/arduino-0022/hardware/arduino/cores/arduino ~/arduino-0022/hardware/arduino/cores/arduino/main.cpp -o/tmp/build3895633309484179111.tmp/main.cpp.o
avr-g++ -c -g -Os -w -fno-exceptions -ffunction-sections -fdata-sections -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=22 -I~/arduino-0022/hardware/arduino/cores/arduino ~/arduino-0022/hardware/arduino/cores/arduino/HardwareSerial.cpp -o/tmp/build3895633309484179111.tmp/HardwareSerial.cpp.o
avr-ar rcs /tmp/build3895633309484179111.tmp/core.a /tmp/build3895633309484179111.tmp/wiring_shift.c.o
avr-ar rcs /tmp/build3895633309484179111.tmp/core.a /tmp/build3895633309484179111.tmp/wiring_digital.c.o
avr-ar rcs /tmp/build3895633309484179111.tmp/core.a /tmp/build3895633309484179111.tmp/wiring.c.o
avr-ar rcs /tmp/build3895633309484179111.tmp/core.a /tmp/build3895633309484179111.tmp/wiring_analog.c.o
avr-ar rcs /tmp/build3895633309484179111.tmp/core.a /tmp/build3895633309484179111.tmp/pins_arduino.c.o
avr-ar rcs /tmp/build3895633309484179111.tmp/core.a /tmp/build3895633309484179111.tmp/wiring_pulse.c.o
avr-ar rcs /tmp/build3895633309484179111.tmp/core.a /tmp/build3895633309484179111.tmp/WInterrupts.c.o
avr-ar rcs /tmp/build3895633309484179111.tmp/core.a /tmp/build3895633309484179111.tmp/Tone.cpp.o
avr-ar rcs /tmp/build3895633309484179111.tmp/core.a /tmp/build3895633309484179111.tmp/WMath.cpp.o
avr-ar rcs /tmp/build3895633309484179111.tmp/core.a /tmp/build3895633309484179111.tmp/WString.cpp.o
avr-ar rcs /tmp/build3895633309484179111.tmp/core.a /tmp/build3895633309484179111.tmp/Print.cpp.o
avr-ar rcs /tmp/build3895633309484179111.tmp/core.a /tmp/build3895633309484179111.tmp/main.cpp.o
avr-ar rcs /tmp/build3895633309484179111.tmp/core.a /tmp/build3895633309484179111.tmp/HardwareSerial.cpp.o
avr-gcc -Os -Wl,--gc-sections -mmcu=atmega328p -o /tmp/build3895633309484179111.tmp/sketch_apr28a.cpp.elf /tmp/build3895633309484179111.tmp/sketch_apr28a.cpp.o /tmp/build3895633309484179111.tmp/LibreriaA/Classe.cpp.o /tmp/build3895633309484179111.tmp/core.a -L/tmp/build3895633309484179111.tmp -lm

HELP :cold_sweat:

found the solution: recessiveness is used only for core libraries...

I've recompiled arduino IDE with some changes and everythings now work!!! take a look here for the solution: Google Code Archive - Long-term storage for Google Code Project Hosting.

News in the code, and I won't update this post, look here for news: Google Code Archive - Long-term storage for Google Code Project Hosting.
and the post on Italian forum http://arduino.cc/forum/index.php/topic,59585.15.html