pstack on Solaris gives you a stack dump for all active threads. But this might be too heavy for some applications.
libunwind is a Linux library that provides stack unwinding routines.
The link below gives a method of doing it with functions on Solaris.
techno's scratchpad: C/C : Printing Stack Trace with printstack() on Solaris
But this works only for Solaris 9 onwards...
Check this for some Linux info
For Windows information