Showing posts with label external library. Show all posts
Showing posts with label external library. Show all posts

Friday, 24 August 2012

Extending NS3 with your module and extra libraries

I have been working on custom module in ns3 for some time now. Due to many changes in NS3, like bug fixes, extensions, improvements, I decided to move to latest version.

This decision consumed couple of days and several gray hair, due to lack of documentation. The biggest difference for custom module developer is the new waf build system and thus how build works.

Reading http://www.nsnam.org/wiki/index.php/HOWTO_use_ns-3_with_other_libraries it seems very simple to add additional libraries, however the tutorial is not valid for module. Because the suggested build steps will only link the individual files with external libraries and NOT the module. The flags are only passed when compiling indivirual object, the bug (?) is reported.

So here is how I managed to solve it

First, add configuration in your wafscript script
def configure(conf):
     conf.env['xercersc'] = conf.check(mandatory=True, lib='xerces-c', uselib_store='XERCES')
     conf.env['ldl'] = conf.check(mandatory=True, lib='dl', uselib_store='LDL')
 
make sure you change naming to your libs, note also the name of library, you have to omit "lib", "l" and only go by the name. Having mandatory=True will abort the compilation if waf can not find the library.

Second and last

def build(bld):
    #......
    #...... code omited
    #......
    module.use.append("XERCES")
    module.use.append("LDL")
    #......
    #...... the rest of build code
Delete build directory run
./waf configure && ./waf build
If you still having problems with linking it is very useful to run
./waf --no-task-lines -v
In that case after each build step waf will output runner were the compiler and all passed flags are visible. From there you can continue bug hunt :)

Cheers