I played around with this when the library was first posted, trying to understand how it all worked.
The problem is not including HardwareSerial.h but using Serial, Serial1 etc.
The first time you call Serial.begin() you will pull in all the code in HardwareSerial. If you reference a library that calls Serial.print() etc you will also pull in the HardwareSerial code.
If it's your library that's causing the problem, the easiest fix is to add a variable to your library:
Stream* activeSerialPort;
and initialise it in setup()
#include <MyLib.h>
void setup()
{
Serial.begin(115200);
activeSerialPort = &Serial;
}
or if you switch to SerialPort:
#include <MyLib.h>
#include <SerialPort.h>
SerialPort<0, 64, 64> serialPort;
void setup()
{
serialPort.begin(115200);
activeSerialPort = &serialPort;
}
HardwareSerial and SerialPort inherit from Stream, so it just works. Remember that any calls in your library will change from Serial.print() to activeSerialPort->print() etc.
Hope that helps.
Iain