Arduino IDE looking for a file it does not need for compiling a sketch

I realy appreciate it if you could help me out with this compile issue.

k_Key_1.h is the only file needed for compiling the sketch test_error.ino, but Arduino IDE is trying to compile l_Key_Layered.cpp for no good reason, which causes a compile failure.
l_Key_Layered depends on c_LayerManager, otherwise the program is straight forward.
The code looks fine to me. Maybe there is something screwy with my system or this is an Arduino bug.

The main .ino file, test_error.ino:

#include <k_Key_1.h>
//#include <c_LayerManager.h>

k_Key_1 k_a;

void setup() { } 
void loop() { }

Arduino\libraries\kb\k_Key_1.h:

#ifndef K_KEY_1_H
#define K_KEY_1_H

class k_Key_1 { };
#endif

Arduino\libraries\kb\l_Key_Layered.cpp:

#include "l_Key_Layered.h"

void l_Key_Layered::press()
{
 refLayerManager.getActiveLayer();
}

Arduino\libraries\kb\l_Key_Layered.h:

#ifndef L_KEY_LAYERED_H
#define L_KEY_LAYERED_H

#include <c_LayerManager.h> //Ardiuino IDE needs this in angle brackets (Make can also use quotes)

class l_Key_Layered
{
 private:
 static c_LayerManager& refLayerManager;
 public:
 void press();
};
#endif

Arduino\libraries\kb_L\c_LayerManager.cpp:

#include "c_LayerManager.h"

void c_LayerManager::getActiveLayer()
{
}

Arduino\libraries\kb_L\c_LayerManager.h:

#include "c_LayerManager.h"

void c_LayerManager::getActiveLayer()
{
}

The error with verbose turned on:

Arduino: 1.0.6 + Td: 1.20 (Windows 7), Board: "Teensy 2.0"
C:\Program Files (x86)\Arduino\hardware\tools\avr\bin\avr-g++ -c -g -Os -Wall -fno-exceptions -ffunction-sections -fdata-sections -mmcu=atmega32u4 -DF_CPU=16000000L -MMD -DUSB_VID=null -DUSB_PID=null -DARDUINO=106 -DTEENSYDUINO=120 -felide-constructors -std=c++0x -DUSB_HID -DLAYOUT_US_ENGLISH -IC:\Program Files (x86)\Arduino\hardware\teensy\cores\teensy -IC:\Users\wolf\Documents\Arduino\libraries\kb C:\Users\wolf\AppData\Local\Temp\build904082142958979008.tmp\test_error.cpp -o C:\Users\wolf\AppData\Local\Temp\build904082142958979008.tmp\test_error.cpp.o 

C:\Program Files (x86)\Arduino\hardware\tools\avr\bin\avr-g++ -c -g -Os -Wall -fno-exceptions -ffunction-sections -fdata-sections -mmcu=atmega32u4 -DF_CPU=16000000L -MMD -DUSB_VID=null -DUSB_PID=null -DARDUINO=106 -DTEENSYDUINO=120 -felide-constructors -std=c++0x -DUSB_HID -DLAYOUT_US_ENGLISH -IC:\Program Files (x86)\Arduino\hardware\teensy\cores\teensy -IC:\Users\wolf\Documents\Arduino\libraries\kb -IC:\Users\wolf\Documents\Arduino\libraries\kb\utility C:\Users\wolf\Documents\Arduino\libraries\kb\l_Key_Layered.cpp -o C:\Users\wolf\AppData\Local\Temp\build904082142958979008.tmp\kb\l_Key_Layered.cpp.o 

In file included from C:\Users\wolf\Documents\Arduino\libraries\kb\l_Key_Layered.cpp:1:
C:\Users\wolf\Documents\Arduino\libraries\kb\/l_Key_Layered.h:4:99: warning: c_LayerManager.h: No such file or directory
In file included from C:\Users\wolf\Documents\Arduino\libraries\kb\l_Key_Layered.cpp:1:
C:\Users\wolf\Documents\Arduino\libraries\kb\/l_Key_Layered.h:9: error: ISO C++ forbids declaration of 'c_LayerManager' with no type
C:\Users\wolf\Documents\Arduino\libraries\kb\/l_Key_Layered.h:9: error: expected ';' before '&' token
C:\Users\wolf\Documents\Arduino\libraries\kb\l_Key_Layered.cpp: In member function 'void l_Key_Layered::press()':
C:\Users\wolf\Documents\Arduino\libraries\kb\l_Key_Layered.cpp:5: error: 'refLayerManager' was not declared in this scope

I am running Arduino 1.0.6 on Windows 7.
I created a new library and recreated the error in the new library.

Somebody please copy these files and see if you can reproduce the error on your system.
The library files are attached.
The follow are step-by-step instructions for recreating the error.

Create two Arduino libraries:
Arduino\libraries\kb
Arduino\libraries\kb_L\

Add the libraries to the Arduino IDE:
Sketch > Import Library… > Add Library… >

Copy these files into Arduino\libraries\kb:
k_Key_1.h
l_Key_Layered.cpp
l_Key_Layered.h

Copy these files into Arduino\libraries\kb_L:
c_LayerManager.cpp
c_LayerManager.h

Compile test_error.ino (the above error is displayed).

The code can be made to compile by adding an include.
In file test_error.ino, uncomment “#include <c_LayerManager.h>” (a user of the kb library would not know to include this file from the kb_L library)

After test_error.ino compiles, Arduino has the c_LayerManager object file and no longer needs the include.
To repeat the error again, delete your test_error.ino build e.g. AppData\Local\Temp\build574758465065038380.tmp
Close Arduino IDE, reopen Arduino IDE, comment “#include <c_LayerManager.h>” and compile.

I first posted this problem on http://forum.arduino.cc/index.php?topic=287599.0 How to clean Arduino IDE?

Thank you for your assistance.

kb.zip (928 Bytes)

kb_L.zip (641 Bytes)

Dear wolfv,

I already replied the thread . You haven’t checked answer??

Create Newtab-> save file name as k_Key_1.h

#ifndef K_KEY_1_H
#define K_KEY_1_H

class k_Key_1 { };
#endif

In main code, header file should be defined as below.

#include "k_Key_1.h"
//#include <c_LayerManager.h>

k_Key_1 k_a;

void setup() { } 
void loop() { }

If you want to use like extention<>

Then create a folder , then define your header file & .cpp file their. then import library in main.
Let me know if you get any error.

Please share your code in Zip file. So i can show you exact ouput here.

@wolfv:
please don't cross post.