Using serial.print to debug a library

There are many bugs in that last stuff you posted. The sketch looks fine. The source file looks like a header file. The header file has an include guard that is useless.

MyLibrary.h should look like:

#ifndef _MYLIBRARY_H
#define _MYLIBRARY_H
#if defined(ARDUINO) && ARDUINO >= 100
#include "Arduino.h"
#else
#include "WProgram.h"
#endif

class MyLibrary {
  public:
    //pass a reference to a Print object
    MyLibrary( HardwareSerial &print );
    void test();
  private:
    HardwareSerial* printer;
};
#endif

It's hard to say what MyLibrary.cpp should look like, at this point. At a minimum, it needs to #include MyLibrary.h.