compiler error developing library based on NewSoftSerial

I am trying to write a library that interfaces with a serial device, and I want to use a NewSoftSerial (NSS) port to do so. I've written code in the past using NSS, so at that level (I think) I know what I am doing there. But I am trying to put together all the code relevant to the device into a class. I have a bunch of code, but I've stripped things down to a small .cpp, a small .h, and a small sketch that together show the problem I'm encountering (using Arduino 022 on Windows).

Here's the contents of the file TESTLIB.h:

#ifndef TESTLIB_H
#define TESTLIB_H

#include <WProgram.h>
#include "../NewSoftSerial/NewSoftSerial.h"

class TESTLIB : NewSoftSerial
{
public:
	TESTLIB ( uint8_t receivePin, uint8_t transmitPin );
	~TESTLIB ( void );
};

#endif

Here's the contents of TESTLIB.cpp:

#include <WProgram.h>
#include "TESTLIB.H"

TESTLIB::TESTLIB ( uint8_t receivePin, uint8_t transmitPin ) : NewSoftSerial ( receivePin, transmitPin )
{
	begin ( 9600 );
}

TESTLIB::~TESTLIB ( void )
{
}

And here's the code in my sketch:

#include <TESTLIB.h>

TESTLIB tl ( 1, 2 );

void setup ( )
{
}

void loop ( )
{
}

The errors I get back from the compiler are as follows:

TESTLIB\TESTLIB.cpp.o: In function `~TESTLIB':
C:\Users\TASTEWAR\Documents\Arduino\libraries\TESTLIB/TESTLIB.cpp:11: undefined reference to `NewSoftSerial::~NewSoftSerial()'
TESTLIB\TESTLIB.cpp.o: In function `TESTLIB':
C:\Users\TASTEWAR\Documents\Arduino\libraries\TESTLIB/TESTLIB.cpp:4: undefined reference to `NewSoftSerial::NewSoftSerial(unsigned char, unsigned char, bool)'
C:\Users\TASTEWAR\Documents\Arduino\libraries\TESTLIB/TESTLIB.cpp:6: undefined reference to `NewSoftSerial::begin(long)'
TESTLIB\TESTLIB.cpp.o:(.rodata._ZTV7TESTLIB+0x4): undefined reference to `NewSoftSerial::write(unsigned char)'

Can anyone help me understand what I've done wrong? Also, with the NSS lib installed in my user libraries area, I have to use the funky relative path reference. Is there a better way? How should a user library build upon another user library?

Thank you!

Because of the way that Arduino puts things together so that it knows what to compile and link, you have to include <NewSoftSerial.h> in your main sketch.

It's a little quirk. (We all have our little quirks, right?)

Regards,

Dave

Wow! What a great community -- the answer to a problem that's been giving me grief for hours, solved in mere minutes! A little experimentation shows that the #include is indeed required in both places. Does seem quirky, but it's a big relief to understand.

Thanks, davekw7x!

Is there a better/cleaner way to reference the NewSoftSerial.h file from TESTLIB.h?

tastewar:
...Is there a better/cleaner way to reference the NewSoftSerial.h file from TESTLIB.h?

I don't know. I don't see any particular downside to using the relative path. I mean with the current version of Arduino we don't have any control over the compiler command line when we compile from inside the Arduino IDE, and I don't know of any other way to tell the compiler where to look.

Maybe somebody who has come up with something more pleasing to your sensibilities can offer suggestions.

Regards,

Dave

tastewar:
Is there a better/cleaner way to reference the NewSoftSerial.h file from TESTLIB.h?

How do you feel about adding / altering an environment variable?

I just want to know that that's the way someone else would do it, given the same situation.

I guess I'd rather leave it in a state that would be compatible with most peoples' installs. I'd rather dictate that NSS must be installed in the standard location than require someone to add/modify an env. var. But thanks!