Search code examples
ns2

Installing Network Simulator 2 on manjaro system


I tried to install ns2 on 4.9.68-1-MANJARO but got this error

    mdart/mdart_adp.cc:396:21: error: reference to ‘hash’ is ambiguous
  nsaddr_t dstAdd_ = hash(mdart_->id_);
                     ^~~~
In file included from ./mdart/mdart.h:52:0,
                 from ./mdart/mdart_adp.h:51,
                 from mdart/mdart_adp.cc:47:
./mdart/mdart_function.h:230:17: note: candidates are: nsaddr_t hash(nsaddr_t)
 inline nsaddr_t hash(nsaddr_t id) {
                 ^~~~
In file included from /usr/include/c++/7.2.1/bits/basic_string.h:6575:0,
                 from /usr/include/c++/7.2.1/string:52,
                 from /usr/include/c++/7.2.1/bitset:47,
                 from ./mdart/mdart_function.h:62,
                 from ./mdart/mdart.h:52,
                 from ./mdart/mdart_adp.h:51,
                 from mdart/mdart_adp.cc:47:
/usr/include/c++/7.2.1/bits/functional_hash.h:58:12: note:                 template<class _Tp> struct std::hash
     struct hash;
            ^~~~
make: *** [Makefile:94: mdart/mdart_adp.o] Error 1
Ns make failed!

I changed line 137 from

void eraseAll() {erase(baseMap::begin(), baseMap::end()); }

to

void eraseAll() { baseMap::erase(baseMap::begin(), baseMap::end()); } 

but, still got the same error. Please help me.


Solution

  • I changed the line 7 of otcl-1.14/Makefile.in to CC= gcc-4.9.3

    The most important gcc component here is g++.

    Building ns-2.35 with gcc-4.9.3 / g++-4.9.3 :

    $ tar xvf ns-allinone-2.35_gcc5.tar.gz
    $ cd ns-allinone-2.35/
    $ export CC=gcc-4.9.3 CXX=g++-4.9.3 && ./install
    $ cd ns-2.35/
    # make install
                      // 'make install' will copy 'ns' to /usr/local/bin/
    # cd ../nam-1.15/
    # make install && exit
    

    Note : The (temporary) export command will take care that the main applications in ns-allinone are compiled with gcc-4.9.3 / g++-4.9.3 : tcl, tk, otcl, tclcl, ns-2.35, nam-1.15 . When exiting the terminal, the export command is cancelled.


    EDIT Aug 31, 2020 : gcc49-bin-4.9.3-el6.tar.xz is available https://drive.google.com/file/d/1w0jT6q59rfZ-Bl--G5Y6jRVjjxu4CH68/view?usp=sharing

    cd /usr/local/
    # tar xvf gcc49-bin-4.9.3-el6.tar.xz
    # cd bin/
    # ln -s ../gcc493/bin/gcc49
    # ln -s ../gcc493/bin/g++49