在 manjaro 系统上安装 Network Simulator 2

Installing Network Simulator 2 on manjaro system

我尝试在 4.9.68-1-MANJARO 上安装 ns2 但出现此错误

    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!

我从

更改了第 137 行
void eraseAll() {erase(baseMap::begin(), baseMap::end()); }

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

但是,还是出现同样的错误。请帮助我。

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

这里最重要的 gcc 组件是 g++

使用 gcc-4.9.3 / g++-4.9.3 构建 ns-2.35 :

$ 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

注意:(临时)导出命令将注意 ns-allinone 中的主要应用程序是使用 gcc-4.9.3 / g++-4.9.3 编译的:tcl、tk、otcl、tclcl,ns-2.35, nam-1.15 。退出终端时,导出命令被取消


编辑 2020 年 8 月 31 日:gcc49-bin-4.9.3-el6.tar.xz 可用 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

我们必须编辑 ns-allinone-2.35 的源代码。它包含一些错误:

ns-allinone-2.35/ns-2.35/mdart/中我们必须编辑3个文件

  • 第一个文件是 mdart_function.h ,在第 230 行将 hash 重命名为 hash_
  • 第二个文件是 mdart_adp.cc ,在行号 108396 重命名 hashhash_ .

Reason why we need to change hash to hash_ is.! , hash is STL library utility , so it will directly refers to STL std::hash . so that I renamed hash to hash_

  • 第三个文件是 mdart_function.h ,在第 48 行重写行 #define __mdart_rqueue_h__ .

Reason is , If we are writing header file then 1st we have to write like,

#ifdefn __filename_h__
#define __filename_h__

in filename.h only .

现在在ns-allinone-2.35/ns-2.35/linkstate/中我们必须编辑ls.h文件

  • 在第 64 行重写 #ifndef __ls_h__ 并且 65 应该像 #define __ls_h__

就是这样。在此之后去安装。