Friday, November 11, 2011

Compile NS-2.34 and 2.35 with GCC-4.6

I stumbled into the compilation issue after upgrading to Ubuntu Oneiric 11.10. The error occurs in "mac-802_11Ext.h" saying something like the following:
mac/mac-802_11Ext.h: In member function 'u_int32_t PHY_MIBExt::getHdrLen11()':mac/mac-802_11Ext.h:175:19: error: expected primary-expression before 'struct'mac/mac-802_11Ext.h:175:41: error: 'dh_body' was not declared in this scopemac/mac-802_11Ext.h:175:51: error: 'offsetof' was not declared in this scope
I found the solution in Ubuntu's patched version of NS-2.35-RC6. The direct link to the patch is here: http://launchpadlibrarian.net/74445224/ns2_2.35~RC6-4_2.35~RC6-4ubuntu1.diff.gz

It's really simple. All you have to do is to add #include cstddef as shown below:
#ifndef ns_mac_80211Ext_h
#define ns_mac_80211Ext_h
#include cstddef
#include "marshall.h"
#include "timer-handler.h"
 Now, NS-2.34 should compile fine with GCC-4.6. Enjoy your simulation!

P.S. BlogSpot is simply terrible for posting code snippets. For clarity, here's a screenshot of what the code should look like.

 

4 comments:

Ahmed Kotb said...

thanks for your post .. fixed my problem :)

by the way it should be
#include
instead of just
#include cstddef

Ahmed Kotb said...

apparently < and > are removed by blogspot
just put < before cstddef and > after it :)

Unknown said...

:) I think Google and BlogSpot is eating up both our left/right arrow-heads. Anyways, I have added a screen-shot for better viewing - http://i.imgur.com/hMUCc.png.

Mariam said...

Thank you :D

Post a Comment