[Ns-developers] Extenral Library Dependency
Gustavo Carneiro
gjcarneiro at gmail.com
Tue Jul 15 14:42:48 PDT 2008
2008/7/15 <craigdo at ee.washington.edu>:
>
> Hi All,
>
> I am going to check some system threading and synchronization classes into
> ns-3-dev shortly. There are dependencies on the pthreads library in these
> classes, and I'm not really sure what the best way to handle this and
> similar cases actually is when using waf.
>
> In the case of pthreads, you need to link with librt. One way to do this
> is
> to add something like,
>
> variant_env.append_value('LINKFLAGS', '-L/lib -lrt')
No need for such complication. In modern gcc compilers, -pthread, in both
CXXFLAGS and LINKFLAGS, is enough to add the necessary options for
compilation and linking with threads support.
Patch attached demonstrating how to apply this to the simulator module.
>
>
> in the "def configure(conf):" function of the top-level wscript. That
> seems
> to be a brute force and awkwardness approach, though. There's got to be a
> better way.
>
> It would be nice to be able to add the dependency at the module level in
> this case. For example, to be able to tell the core wscript that core now
> needs to be linked against librt. I found something called "uselib" that
> seems to do something like that but I haven't had any success in applying
> this.
>
> Another case I'm pondering is a device that might need to link against
> libpcap. Again, it would not be very clever to add a dependency on pcap to
> the whole system when many folks will never use the device in question. It
> would be nice to be able to tell the wscript in src/devices/x that code
> linking against this device needs also to link libpcap; and only actually
> resolve references if a script needs to use the 'x' device.
Attached patch also takes care of libcap (as example).
>
>
> This brings me to yet another point. Since we started monolithically
> linking into a gargantuan libns-3 library, we seem to have lost track of
> how
> we need to specify dependencies in the wscripts.
>
> It used to be the case that we had to explicitly add libraries as in,
>
> obj = bld.create_ns3_program('wifi-adhoc',
> ['core', 'simulator', 'mobility', 'wifi'])
>
> but now, I believe that
>
> obj = bld.create_ns3_program('wifi-adhoc')
>
> works just as well; and some examples seem to have incomplete lists of
> module dependencies.
>
> Anyway, I'm not sure how this should all play out, and where the
> declarations of library dependencies should actually go and whether or not
> the lists in wscripts are meaningful. Can one of you waf guru-types give
> me
> a hand doing this in a sane way?
Library dependencies are taken care in my patch. Basically if you define
CXXFLAGS_FOOBAR, and in your module you add module.uselib = 'FOOBAR' then
those CXXFLAGS are applied to that module and any other module that depends
on this module. Same thing for other variables like LIBS, LINKFLAGS, etc.
Regarding program and module dependencies, I think we should keep them. In
the future someone might want to experiment with ways to make this build
less monolithic, for one thing, and dependency information might come
handy. Additionally, without modules dependency information the WAF option
--enable-modules, which allows us to compile only a selected subset of ns-3
modules, will stop working. It needs dependency information to know which
modules it can build and which applications can be built that depend only on
enabled modules.
Regards.
--
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: uselib-example.diff
Type: text/x-patch
Size: 993 bytes
Desc: not available
Url : http://mailman.isi.edu/pipermail/ns-developers/attachments/20080715/1470494c/uselib-example.bin
More information about the Ns-developers
mailing list