To keep up the pace with new versions of Ubuntu and potentially new installation problems with ns-2, here is a recipe for installing ns-2.34 on Ubuntu 10.10:

Download and extract ns-2.34 to a folder in your home directory. Get ns-2.34 allinone here.

Install the development files for X Windows plus the g++ compiler:
sudo apt-get install xorg-dev g++ xgraph

Fix the error in the linking of otcl by editing line 6304 of otcl-1.13/configure so that it reads
SHLIB_LD="gcc -shared"
instead of
SHLIB_LD="ld -shared"

And run ./install

Good luck!

See also: Installing ns-2.34 on Ubuntu 11.10 Oneiric Ocelot