Making use of external libraries in NS3

There are have been some articles introducing how to make used of external libraries in NS3, such as

HOWTO use ns-3 with other libraries

Extending NS3 with your module and extra libraries


But they are not very straightforward, or it took me a little while to make it work. So I’ll simply repass the HOWTO with more details here.

  1. The first step is, of course, make your own libraries or the third-party library ready. If you want to build your own libraries, you can check

Static, Shared Dynamic and Loadable Linux Libraries

Assuming now we have a static library named libctest.a and header file ctest.h. 

2. In the wscript file of your module, add the following code:

def configure(conf):


def build(bld):


ATTENTION: the file names and lib names are important!!

If you are using third party libraries, you probably need to define the LD_* variables accordingly.

3. Reconfigure and rebuild ns3 with, if it’s a static library

./waf configure –enable-static

and then

./waf build

4. In the code where you need to make used of the library, include the header files like:

extern “C”{ //we are using c here

#include <ctest.h>


Now you can make used of the functions defined in the lib.


%d bloggers like this: