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.


This entry was posted in 技术 Tech. Bookmark the permalink.

One Response to Making use of external libraries in NS3

  1. Ouss says:

    Could you help me please ? I have my program called “rate-adaptation” on NS3 under scratch folder. It runs perfectly. Now, I want to use CPLEX libraries installed in “/opt/ibm/ILOG/CPLEX_Studio127/” from my program. The problem is that I get the error:
    ../scratch/rate-adaptation/server.h:22:26: fatal error: ilopl/iloopl.h: No such file or directory

    Couldu you please tell me what is wrong ?

    My wscript file under scratch/rate-adaptation looks like :
    def configure(conf):

    def build(bld):
    obj = bld.create_ns3_program(‘rate-adaptation’, [‘core’, ‘stats’, ‘point-to-point’, ‘internet’, ‘applications’])
    obj.source = ‘’

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.