LBNL Network Simulator - Notes on compilers and other problems

Notes on older versions of gcc with ns:

If you are getting the following error messages when compiling ns, you could be using an old version of gcc. ns does not run correctly with versions of gcc older than 2.7.2.

Error messages with older versions of gcc, reported by Mark Allman ( for version 2.6.3 of gcc:

> agent.h:67: method `void Agent::sched(double, int)' is protected
> agent.h:68: method `void Agent::cancel(int)' is protected
> agent.h:54: method `class Packet * Agent::allocpkt(int, int = 0) const' is protected

While one fix for this, with an older compiler, is to change the "protected" procedures to "public", this change could also introduce other problems, and is not recommended.

The following error messages can also result from running ns with older versions of gcc (e.g., v2.5.8). Reported by Gi Kim (

% ns test-suite.tcl reno2
ns: no such command: _a10 source ftp

The problem results from the "command" function for the RenoTcpAgent object being called from the grandparent (Agent) object rather than from the parent (TcpAgent) object.

Problems linking ns

A number of people have had problems linking ns due to difficulties related to dynamic versus static libraries. On SunOS, this problem is indicated by the following output:
	collect2: ld returned 2 exit status
	ld: Undefined symbol
The problem is caused by the (static) tcl library making references to functions defined in the (dynamic) dl library on SunOS systems. A temporary fix for this problem is to edit the file, and replace the lines:
	ns.dyn: $(OBJ)
		$(C++) -o $@ $(CFLAGS) $(OBJ) $(LIB)
with the following lines:
	ns.dyn: $(OBJ)
		$(C++) -o $@ $(CFLAGS) $(OBJ) -Xlinker -Bstatic -ltcl7.5 -lm -Xlinker -Bdynamic -ldl
Then rerun "./configure" and do "make ns.dyn". It will produce an executable ns.dyn that should run. The above change causes the linker to use a static version of the tcl library and the dynamic version of the dl library. If you are using some version of the tcl library not called libtcl7.5.a you may have to replace "-ltcl7.5" above with whatever your library is called.

Notes of using the SunPro C++ v3.0.1 compiler:

Patches to port ns-1.0a16 to Solaris 2.4 with SunPro C++ v3.0.1.

Back to [ns].
Steve McCanne (
Sally Floyd (