编译NS3.13,记录一下自己遇到的问题与解决方法,以便以后查看和帮助遇到相同问题的人。
建议先使用eclipse编译一边,因为eclipse可以方便的跟踪代码,很快就能找到定义。而在编译过程中遇到比较多的问题就是定义和包含问题。
环境:ubuntu12.04 64位系统
GCC:gcc version 4.6.3 (Ubuntu/Linaro 4.6.3-1ubuntu5)
1.simple-network-coding.cc:115:21: error: ‘NscTcpL4Protocol’ was not declared in this scope
2.more-network-coding-protocol.cc:75:12: error: ‘NscTcpL4Protocol’ was not declared in this scope
很明显这是没有包含NscTcpL4Protocol的缘故。
其中1,2中的错误后面还会涉及到link的问题,需要修改../NS3-13/src/internet/wscript中的:
if bld.env['NSC_ENABLED']:
obj.source.append ('model/nsc-tcp-socket-impl.cc')
obj.source.append ('model/nsc-tcp-l4-protocol.cc')
obj.source.append ('model/nsc-tcp-socket-factory-impl.cc')
obj.source.append ('model/nsc-sysctl.cc')
headers.source.append('model/nsc-tcp-l4-protocol.h')
obj.use.append('DL')
internet_test.use.append('DL')
改为
# if bld.env['NSC_ENABLED']:
if 1:
obj.source.append ('model/nsc-tcp-socket-impl.cc')
obj.source.append ('model/nsc-tcp-l4-protocol.cc')
obj.source.append ('model/nsc-tcp-socket-factory-impl.cc')
obj.source.append ('model/nsc-sysctl.cc')
headers.source.append('model/nsc-tcp-l4-protocol.h')
obj.use.append('DL')
internet_test.use.append('DL')
即将这些文件编译进去,注意这里的if 1:一定吆喝原来注释前的if对齐,不然在./waf configure 时会报错
3.cannot call constructor ‘ns3::BearLogisticFunction::BearLogisticFunction’ directly
找到bear-error-model.cc中报错的3句话
m_dataLogParams = BearLogisticFunction::BearLogisticFunction (1.24, 0.366, 6.88, 3, 16);
m_ackLogParams = BearLogisticFunction::BearLogisticFunction (1.00, 0.886, 6.88, 0, 13);
m_bcastCtrlLogParams = BearLogisticFunction::BearLogisticFunction (1.9, 0.6, 0.0, 0, 10);
改为:
m_dataLogParams = BearLogisticFunction (1.24, 0.366, 6.88, 3, 16);
m_ackLogParams = BearLogisticFunction (1.00, 0.886, 6.88, 0, 13);
m_bcastCtrlLogParams = BearLogisticFunction (1.9, 0.6, 0.0, 0, 10);
即去掉前面的BearLogisticFunction::,原因是由于gcc版本提高后对类内部函数调用的简化造成的不兼容