summer
summer

Reputation: 149

ns2 mpolsr compilation error for wsn

I am trying to compile the mpolsr patched ns-2.29 in Linux Mint with gcc-4.7. I am getting the following error:

trace/cmu-trace.o: In function `MPOLSR_pkt::access(Packet const*)':
cmu-trace.cc:(.text._ZN10MPOLSR_pkt6accessEPK6Packet[_ZN10MPOLSR_pkt6accessEPK6Packet]+0x7): undefined reference to `MPOLSR_pkt::offset_'
collect2: error: ld returned 1 exit status
make: *** [ns] Error 1

I am finding that the cmu-trace.cc file includes the correct header. I tried t add the cc file which has the definition of the offset function but no success. Any help will be appreciated.

I am using ns-2.29_mpolsr.rar.

Upvotes: 1

Views: 1053

Answers (1)

user000001
user000001

Reputation: 33307

The ns-2.29_mpolsr.rar file is broken, in that the authors of mpolsr only changed the Makefile, but not the Makefile.in. Thus, when you run the ./configure, you will erase the changes in the Makefile.

These are the steps you need to do for compiling it:

1. Edit the Makefile.in:

Add the directories olsr and mpolsr to the INCLUDES variable. It should look like this:

INCLUDES = \
        -I. \
        @V_INCLUDES@ \
        -I./tcp -I./sctp -I./common -I./link -I./queue \
        -I./adc -I./apps -I./mac -I./mobile -I./trace \
        -I./routing -I./tools -I./classifier -I./mcast \
        -I./diffusion3/lib/main -I./diffusion3/lib \
        -I./diffusion3/lib/nr -I./diffusion3/ns \
        -I./diffusion3/filter_core -I./asim/ -I./qs \
        -I./diffserv -I./satellite \
        -I./wpan -I./olsr -I./mpolsr

Add the object files of mpolsr to the OBJ_CC variable. You should add a line like this (the one in the middle is the new one):

        olsr/OLSR.o olsr/OLSR_state.o olsr/OLSR_rtable.o olsr/OLSR_printer.o \
        mpolsr/MPOLSR.o mpolsr/MPOLSR_state.o mpolsr/MPOLSR_m_rtable.o mpolsr/MPOLSR_printer.o mpolsr/MPOLSR_rtable.o\
        common/ns-process.o \

If you are using a new version of gcc, you should also add the -fpermissive directive, otherwise it will fail to compile. To do this, change the .cc.o: directive to this:

.cc.o:
        @rm -f $@
        $(CPP) -fpermissive -c $(CFLAGS) $(INCLUDES) -o $@ $*.cc

2. Make the configure script executable

In the ns-2.29_mpolsr directory, run

chmod +x configure

3. Run the configure script

Depending on the allinone version of ns, you run something like this:

./configure --with-otcl=$PWD/../otcl-1.13/ --with-tclcl=$PWD/../tclcl-1.19/

The above version numbers are for ns-allinone-2.34

4. Make

In the same directory run

make -j100

I checked the above with gcc-4.6.3, but it should also work with gcc-4.7.

Upvotes: 1

Related Questions