在eclipse中配置ns3

来源:互联网 发布:淘宝幽默卖家自动回复 编辑:程序博客网 时间:2024/04/29 18:32

1、  在eclipse中编译ns3

1) 安装eclipse和C/C++语言插件CDT:

sudo apt-get install eclipse

sudo apt-get install eclipse-ctd

2) 在eclipse中配置对ns3的支持:

新建C++工程,此处project name用ns3的版本号命名,为ns319

路径选择/home/workspace/ns-allinone-3.19/ns-3.19(提前将编译好的ns-allinone-3.19拷贝过去,不让该路径不存在)

project type选择 empty project

toolchains选择linux gcc

3) 设置eclipse中ns3编译器为waf

在ProjectExplorer中的ns319上右击,选择properties,做如下操作:

在C/C++ build 中的 Build Settings 选项卡如图所示,去掉 use default build command 和generate makefile sautomatically复选框中的钩,并在 build command和build directory中输入如下图:

加载中

在 C/C++ Build 的 Behavior 选项卡中,Workbench BuildBehavior 中的复选框都选上,第一个值为空,第二个值为build(有的教程第二个为空)最后一个是 clean。具体如下图:

加载中

右击ProjectExplorer下的ns319,选择buildproject,编译程序。第一次编译时会出现报错:Theproject was not configured: run "waf configure" first!”需要到ns-3.19目录下打开终端,之行./waf configure(或者./waf configure --enable-examples --enable-tests,examples和tests默认是不编译的)进行配置。然后再buildproject,编译成功。

2、  在eclipse使用外部工具执行ns3程序

1) Run->ExternalTools->ExternalTools Configurations:如图所示

加载中

2) 右击“Program”——>new,name起为“ns3-waf”,修改location和working directory如下图:

加载中

最后选择run,就可以运行了,运行弹出来的对话框中填入要运行的文件的名字就可以了,例如scratch-simulator,后面不跟.cc。

加载中

运行成功出现以下字样:

加载中

3、  设置debugger

右击ProjectExplorer中的ns319,选择debug as——>debug configurations,进行配置

1) main标签中,填写C/C++Application:build/scratch/scratch-simulator(你的app的路径,可以使用SearchProject...按钮来选择),填写Project:ns319(项目名)

2) environment标签中,新增环境变量 LD_LIBRARY_PATH :/home/ns3/ns3_workspace/ns-allinone-3.25/ns-3.25/build

加载中


希望大家都开心幸福~

祝科研顺利~

0 0
原创粉丝点击