HOWTO use ns-3 with other libraries
Main Page - Roadmap - Summer Projects - Project Ideas - Developer FAQ - Tools - Related Projects
HOWTOs - Installation - Troubleshooting - User FAQ - Samples - Models - Education - Contributed Code - Papers
If you develop a new module that requires use of other system libraries, you will want the waf build system to find the appropriate headers and libraries. This is a brief note of how you might do this, motivated by this ns-3-users thread.
For example, suppose the new module requires these flags:
g++ -Wall -O3 -fopenmp -DLAPACK -DLUSOLVER=LAPACK GenrFail.o sim.o - L../../src -lthyme -llapack -L/usr/local/src/GotoBLAS2 -lblas
You can specify some extensions in your wscript such as:
conf.env.append_value("CXXFLAGS", ["-Wall", "-O3", "-fopenmp"]) conf.env.append_value("CXXDEFINES", ["LAPACK", "LUSOLVER=LAPACK"]) conf.env.append_value("LINKFLAGS", ["-llapack", "-L/usr/local/src/GoToBLAS2", "-lblas", "-Lsrc/common", "-lthyme"])
Make sure to replace CXX with CC if you are compiling C sources instead of C++ ones.
Another example of this can be found in the wifi device, and the approach could be copied. Some files in src/devices/wifi depend on GNU Scientific Library (GSL), and when GSL is installed, we want to use it. We want -lgsl -lm -lgslcblas to be appended. In the src/devices/wifi/wscript, you can see this:
if bld.env['ENABLE_GSL']: obj.uselib = 'GSL GSLCBLAS M'
where ENABLE_GSL is set in the top-level wscript (search for "have_gsl" in the top wscript where the configuration check is done).