Configure the GUI debugging environment for NS2.

Source: Internet
Author: User

In early versions of NS2. in earlier versions, the VC debugging environment in Windows was supported, but it seems that ns2.27 was not supported. Therefore, it is best to use NS2. is there any graphic debugging environment under NS2?

 

Environment: Eclipse 3.5.1 + CDT (see the previous installation)

 

 

1. Start eclipse and create a C ++ project;

 

Select makefile for the project type, select Linux C ++ for the compiler (it is not clear that it is different from cross C ++), select ns-2.3 for the project path *;

 

2. Compile with the error: G ++ not found. However, I have installed build-essential. No way. reinstall an article and find that you want to install g ++.

 

$ Sudo apt-Get install build-essential

 

3. It is found that the starting point of ns is the ns_tclsh.cc file under the root directory, where there is a main function.

In this step, you cannot set a breakpoint for debugging. You must first add the debugging option on makefile. Method:

 

$./Configure -- enable-Debug

 

In this step, you can add the debugging item-G to the makefile. In fact, the ccopt option in the makefile is modified, and-g-wno-Parentheses-werror is added to it.

 

After adding the following two items, during compilation in eclipse, we will find that many previously warning information will be considered as error.

 

4. next, according to The http://hi.baidu.com/aoxinguy/blog/item/4eb310184d545373dbb4bd5f.html prompts, add the trace debugging information of the Tcl library, that is, modify the MAKEFILE file in tcl8.4. */Unix, change it from the optimized mode to the debug mode, as follows:

 

# To change the compiler switches, for example to change from optimization
# Debugging symbols, change the following line:
# Cflags = $ (cflags_debug)
# Cflags = $ (cflags_optimize)
# Cflags = $ (cflags_debug) $ (cflags_optimize)
Cflags = $ (cflags_optimize)-dtcl_dbgx = $ (tcl_dbgx)

Change

# To change the compiler switches, for example to change from optimization
# Debugging symbols, change the following line:
# Cflags = $ (cflags_debug)
# Cflags = $ (cflags_optimize)
Cflags = $ (cflags_debug) $ (cflags_optimize)
# Cflags = $ (cflags_optimize)-dtcl_dbgx = $ (tcl_dbgx)

 

Then re-compile in the current directory:

Make clean

Make

Recompile and generate the libtcl8. *. A and libtclstub. *. A static library files. These two files will be used in NS2. Note that the generated new library must be copied to the ns2.3 */lib directory.

 

Correspondingly, you also need to manually modify the makefile of several other static libraries and re-compile it, that is, TCL-> TK-> OTCL-> tclcl. Pay attention to the compilation sequence.

The above tcl and TK installation methods are the same, but the OTCL installation is different.

 

First enter the OTCL directory, and then:

$ Make clean

Then manually modify the configure file. Otherwise, an error occurs during ns2.34 Compilation:

Set the 6304 rows of the configure file

Shlib_ld = "LD-shared"

Change

Shlib_ld = "gcc-shared"

 

Then generate the MAKEFILE file as follows:

$./Configure -- enable-Debug

 

Finally:

$ Make

 

Thanks for the information provided by aoxingguy, which is very useful and powerful !!

 

Note: As a matter of fact, it took me a week to install the tclappinit function, and I was not able to trace the process as I said before. Finally, download a new version ns2.34 and follow the install steps to complete it step by step. The real cause is that one of my environment variables LD_LIBRARY_PATH is set incorrectly. As a result, when debugging in eclipse, the following message is always prompted:

 

Reading symbols from/home/fanzz/ns-allinone-2.34/ns... done.
Stopped due to shared library event
Stopped due to shared library event

 

 

Refer:

 

Debug NS2.

Same as above

Debug NS2.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.