Importing a library (Ethernet.h) from another one

I’m facing following problem, during importing the Ethernet.h library.

This is fully working (the main project file):

#include "ImageLoader.h"
#include <SPI.h>
#include <Ethernet.h>

EthernetClient client;

void setup() {   
...
}

void loop(){
...
}

However, using the Ethernet Library from another file, brings an error
ImageLoader.cpp

#include <SPI.h>
#include <Ethernet.h>

EthernetClient client;

ImageLoader.cpp:4: error: ‘EthernetClient’ does not name a type

Am I missing something, or is this a bug?

Am I missing something, or is this a bug?

A lot of code for us to look at. No, it isn't a bug in the Arduino IDE or software. In yours, probably. But, we can't see all of your code.

You are right. There was one tiny information missing.

When I put the EthernetClient into the ImageLoader.cpp , I removed it from the main source file.

I just found out, that I need to include those libraries in both files: the main source and the ImageLoader.cpp . It's a little strange for me, but I can live with that.

It’s a little strange for me, but I can live with that.

The reason that you need to tell the sketch about the library is so that needed files get copied to the build directory, so that everything is on one place for compiling and linking.

It would be possible for the IDE to search all include files recursively, but doing so is not trivial. Allowing your library to include another that includes another that includes another would make using your library a nightmare. Examples that you provide would not compile on my system if I didn’t have all the libraries that you have. By exposing them all in the sketch, it is easier to know what libraries are needed for a particular sketch to execute.

Thank your very much for explaining.