need help using the avr-g++ compiler instead of using the IDE

After a day of tinkering and studying I've finally gotten most things to compile using only the command line avr-g++. However, no matter what I do I can't seem to get code using Serial to compile. No matter what I do, whether I precompile .o files and link later, or whether I compile the code directly, I always get this message:

C:\Users\Ryan\AppData\Local\Temp\cc07l64G.o: In function `setup':
test.cpp:(.text+0xa): undefined reference to `Serial'
test.cpp:(.text+0xc): undefined reference to `Serial'
test.cpp:(.text+0xe): undefined reference to `HardwareSerial::begin(unsigned long, unsigned char)'
C:\Users\Ryan\AppData\Local\Temp\cc07l64G.o: In function `loop':
test.cpp:(.text+0x1a): undefined reference to `Serial'
test.cpp:(.text+0x1c): undefined reference to `Serial'
test.cpp:(.text+0x1e): undefined reference to `Print::write(unsigned char const*, unsigned int)'
collect2.exe: error: ld returned 1 exit status

I know this probably has something to do with Serial being declared as an extern Serial_ in USBApi.h, but I don't know how to fix it. Can anyone help???

The Arduino IDE automatically adds this line to your sketch:

#include <Arduino.h>

Did you add that line to your code?

pert:
The Arduino IDE automatically adds this line to your sketch:

#include <Arduino.h>

Did you add that line to your code?

Absolutely, was the first thing I did.

If you set File > Preferences > Show verbose output during: compilation and then compile some code it will show all the compilation commands the Arduino IDE runs. You might do that and then compare them against the commands you're running to see if you can spot the difference.