[Ns-developers] Static NS-3 (Was: icc and "patched" waf)

Gustavo Carneiro gjcarneiro at gmail.com
Fri Jan 23 08:10:08 PST 2009


2009/1/22 Mathieu Lacage <mathieu.lacage at sophia.inria.fr>

> On Thu, 2009-01-22 at 17:42 +0000, Gustavo Carneiro wrote:
>
> > You know it shouldn't be too hard for me to add a configuration switch
> > to ns-3 to compile everything statically.  Do you think this would be
> > useful feature to have in ns-3
>
> I would be happy to pay you drinks until you roll over the table
> whenever you want if you do this.


You can hold the beer.  Unfortunately it's not so simple.

Building NS-3 objects statically is easy, but if I link them into a static
library (.a file), unit tests will fail:

Assert in TypeId::LookupByName: ns3::DefaultSimulatorImpl not found

That is a known problem with static libraries and initialization of C++
global class instances.  Craig wrote a document describing the problem:
http://www.nsnam.org/docs/linker-problems.doc

I can work around by adding all object files directly when linking every
NS-3 program, without even creating a static library, but then linking N
programs each with dozens of object files is very slow and painful.  But
works.  The attached patch does it.

Finally there is the problem of the Python bindings.  Python extension
modules of course need to be 100% -fPIC enabled, including the NS-3 part.
So to make Python bindings work one would need to compile NS-3 twice, once
with -fPIC and another time without.  An alternative to this would be to do
it NS-2 style, i.e. create a NS-3 static program which embeds a Python
library and regsitering a statically built Python builtin module interfacing
with NS-3.

-- 
Gustavo J. A. M. Carneiro
INESC Porto, Telecommunications and Multimedia Unit
"The universe is always one step beyond logic." -- Frank Herbert
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ns-3-static.diff
Type: text/x-patch
Size: 2225 bytes
Desc: not available
Url : http://mailman.isi.edu/pipermail/ns-developers/attachments/20090123/d9dbfd03/ns-3-static.bin


More information about the Ns-developers mailing list