Back to HOWTOs

Installing ns-2.26 in Debian


Ah, ns-2...the bane of many grad student's existence. Useful in software engineering classes as an example of how not to manage complexity in a large scale project. After upgrading my system to a new version of Debian with gcc 4.1.2, I found out that ns-2.26 (on which I had written a ton of code) needs an older version of gcc to compile. This covers the steps I took to get my old code to compile in the new Debian system.

In this example, I assume that your existing ns-2.26 code is in /usr/local/ns-2.26 and that all the original files for the all-in-one distribution are in the /usr/local/dload/ns-allinone-2.26 directory.

Related Pages


  1. Download the all-in-one package of ns-2 and unzip it:
    cd /usr/local/dload;
    tar -xzvf ns-allinone-2.26.tar.gz;
  2. I had to install the following Debian packages:
    • apt-get install gcc-2.95
    • apt-get install g++-2.95
    • apt-get install libstdc++2.10-glibc2.2
    • apt-get install libx11-dev
    • apt-get install libxt-dev
  3. In my shell (tcsh), there were several changes needed in the configure files to compensate for stricter parsing. All lines of the form:

    system=MP-RAS-`awk '{print }' /etc/.relid'`
    need changed to:
    system=MP-RAS-`awk '{print }' /etc/.relid`
    That is, the second to last character (') needs to be deleted. In ns-allinone-2.26, this occurs in four places (files and line numbers):

  4. Set your compiler environment variables in the terminal in which you will run the install script such that they point to the 2.95 version of the tools instead of the default ones. In the C shell:
    setenv CC /usr/bin/gcc-2.95;
    setenv CPP /usr/bin/cpp-2.95;
    setenv CXX /usr/bin/g++-2.95;
    Use the paths appropriate for your system. If you use the bash shell, the general form for setting an environment variable is:
    export CC=/usr/bin/gcc-2.95;
    Now, the configure scripts will use these versions of the compiler tools.
  5. When compiling the TCL/C++ interface (e.g., tclcl-1.0b13), I received a warning that stopped the compilation that line 193 of /usr/include/sys/types.h does not declare anything. Though this is not generally recommended, I used the -fpermissive option for the compiler to continue compilation.

    In the file /usr/local/dload/ns-allinone-2.26/tclcl-1.0b13/, I changed the CCOPT parameter on line 56 to be:

    CCOPT = -fpermissive @V_CCOPT@

  6. At this point, I just had to run the install script an everything compiled (with lots of warnings) except for nam which I didn't need since I don't use the visualization tools in ns-2.
    (Make sure you run this in the terminal in which the CC, CPP, and CXX variables are set appropriately)
  7. Now, to get your existing ns-2 code to compile (i.e., the code in /usr/local/ns-2.26), you need to reconfigure your Makefile by specifying the new paths:
    cd /usr/local/ns-2.26; ./configure --with-tcl=/usr/local/dload/ns-allinone-2.26/tcl8.3.2 --with-tk=/usr/local/dload/ns-allinone-2.26/tk8.3.2 --with-otcl=/usr/local/dload/ns-allinone-2.26/otcl-1.0a8 --with-tclcl=/usr/local/dload/ns-allinone-2.26/tclcl-1.0b13
    Note that this will overwrite your existing Makefile, so if there was anything specific that you needed in it, you should move those commands to the file in /usr/local/ns-2.26.