<! --
@ Page {margin: 2 cm}
P {margin-bottom: 0.21}
A: link {so-language: zxx}
-->
Recently, I am working on a Wireless Sensor Network Positioning Project. Although the hardware equipment is ready, I have not done this step yet, so I can only simulate it. So my boss asked me to use NS2, so I have installed the cygwin Virtual Machine Under Vista, but it cannot generate startxwin. BAT. I have never succeeded, so I installed ubuntu10.04 with my breath. I am going to download NS2. I have read a lot of online installation tutorials and I think they are not completely written, as a result, I failed to install it several times. This afternoon, after I re-installed it again, I finally succeeded. The following describes how to install it.
Enter the following statement in the terminal to install some necessary packages for compilation.
$
Sudo apt-Get install build-essential
$ Sudo apt-Get install tcl8.4
Tcl8.4-dev tk8.4 tk8.4-Dev
$ Sduo apt-Get install libxmu-Dev
Libxmu-headers
Some articles say that GCC needs to be removed, because later GCC versions have an impact on the installation. In fact, you don't need to remove it. There will be a solution later.
Then download the ns2-allinone-2.33.tar.gz package. Put it in the home/jyq (my own folder) and run the following command to decompress the package:
$
Tar xvfz ns-allinone-2.33.tar.gz
Enter the ns-allinone-2.33 folder and enter $
CD./install installation. Wait a few minutes, and an error message will appear:
Make:
* ** [Libotcl. So] Error
1
Otcl-1.13
Make failed! Exiting...
See
Http://www.isi.edu/nsnam/ns/ns-problems.html
For problems
This is because the GCC version is higher.
Ld was used before version 4.0.
-Share to generate the shared library, but to version 4.0 or above, this command is changed to GCC
-Share. Enter GCC in the terminal
-V view, my version is gcc
Version 4.4.1.
Then enter $
CD/ns-allinone-2.33/otcl-1.13, then $
Sudo gedit Configure. In
Put the line 77 shlib_ld = "LD
-Shared ", changed to shlib_ld =" gcc
-Shared ", save and exit. Then
$
Sudo gedit configure
Search for shlib_ld = "LD" in row 5518
-Change shared to shlib_ld = "GCC"
-Shared ", save and exit.
CD back to directory ns-allinone-2.33 and run again
Sudo
./Install
The installation is completed successfully. Finally, the following message is displayed:
Please
Put
/Home/jyq/ns-allinone-2.33/bin/home/jyq/ns-allinone2.33/tcl8.4.18/Unix:/home/jyq/ns-allinone-2.33/tk8.4.18/Unix
Into
Your path environment; so that you'll be able to run
ITM/tclsh/wish/xgraph.
Important
Notices:
(1)
You must put
/Home/jyq/ns-allinone-2.33/otcl-1.13,
/Home/jyq/ns-allinone-2.34/lib,
Into your LD_LIBRARY_PATH
Environment variable.
If it complains about x libraries, add path
To your X Libraries
Into LD_LIBRARY_PATH.
If you are using CSH,
You can set it like:
Setenv LD_LIBRARY_PATH <paths>
If
You are using SH, you can set it like:
Export
LD_LIBRARY_PATH = <paths>
(2)
You must put
/Home/jyq/ns-allinone-2.33/tcl8.4.18/Library
Into your
Tcl_library environmental
Variable. Otherwise NS/NAM will complain
During startup.
After these steps, you can now run the NS validation suite
With
CD ns-2.33;./validate
For trouble shooting, please first read NS Problems
Page
Http://www.isi.edu/nsnam/ns/ns-problems.html. Also search
NS mailing list Archive
For related
Posts.
This is because no environment variable is configured, and then CD enters/home/jyq/, $
Sudo gedit
. Bashrc.
Add the following content to the end of the file:
Path = "$ path:/home/jyq/ns-allinone-2.33/bin:/usr/ns-allinone-2.33/tcl8.4.18/Unix:/home/jyq/ns-allinone-2.33/tk8.4.18/Unix"
LD_LIBRARY_PATH = "/home/jyq/ns-allinone-2.33/otcl-1.13:/usr/ns-allinone-2.33/lib"
Tcl_library = "$ tcl_library:/home/jyq/ns-allinone-2.33/tcl8.4.18/library"
Save and exit. Then reinstall
$
Sudo
./Install.
In this step, it can be said that the installation is complete. Enter ns on the terminal and % indicates that the installation is successful.
However, when running NAM, the following error occurs:
[Code
Omitted because of length]
: No event type or button # Or keysym
While executing
"Bind ListBox <mousewheel> {
% W
Yview scroll [expr {-(% d/120) * 4}] Units
}"
Invoked from
"If {[TK windowingsystem] EQ" classic"
| [TK windowingsystem] EQ "Aqua "}{
Bind ListBox
<Mousewheel> {
% W yview scroll [expr {-(% d)}] Units
}
Bind
Li ..."
I checked it online and said it was the TK component and
Xproto-7.0.13
Caused by incompatibility (xproto-7.0.13
Added
Genericevent), so we need to install patches. Some tutorials say to write a patch and then run, I think this method is not so good, at least for me this cainiao is so, directly in tk-8.4.14/generic/tbbind. add the following code to line 2 of C:
# Ifdef
Genericevent
0,
# Endif
Save and exit. And then reinstall it. The hosts file is not stored in/usr/local/bin/. Then, enter
$
Sudo CP-I NAM/usr/local/bin/
$ Sudo CP-I NS
/Usr/local/bin/
Copy both ns and Nam.
If you run NS again, there should be no problem. At least my machine is okay, and then enter:
$
NS/ns-allinone-2.33/ns-2.33/Tcl/EX/simple. TCL
A simple Nam window will appear. This is all done.