I am getting error messages from the mbed C++ compiler that seem to be indicative of malfunctioning include guards.
In main.cpp, I include my header file as follows:
You need to mark the declarations as "extern" like this:
extern DigitalOut led1;
Then define them (i.e. allocate storage for them) in sample.cpp by using the expression you used to have in the header.