Bug 1490 - module linkflags are dismissed when creating module (cxxshlib)
module linkflags are dismissed when creating module (cxxshlib)
Status: CONFIRMED
Product: ns-3
Classification: Unclassified
Component: documentation
ns-3.11
PC Linux
: P5 normal
Assigned To: Tom Henderson
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2012-08-23 10:27 EDT by Laurynas Riliskis
Modified: 2019-11-05 18:14 EST (History)
5 users (show)

See Also:


Attachments
wscript file from ns-3.18 main directory (43.42 KB, application/octet-stream)
2013-10-14 22:39 EDT, Rohit
Details
wscript file from ns-3.18/src/lte directory (9.18 KB, application/octet-stream)
2013-10-14 22:40 EDT, Rohit
Details
lena-simple.cc in ns-3.18/src/lte/examples directory (5.11 KB, application/octet-stream)
2013-10-14 22:42 EDT, Rohit
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Laurynas Riliskis 2012-08-23 10:27:10 EDT
Hi,

I have discussed the issues (with my self) here
https://groups.google.com/forum/?fromgroups=#!topic/ns-3-users/yeXNs__7C0A

however I am not sure if it is a bug or I could not find documentation how to deal with changed builds (worked with waf 1.5).

Case:
new module is added which have dependences on externals libraries

approach:
create module add to build:
module.env.append_value("LINKFLAGS",["-lxerces-c"])

build

issue:
individual *.o files get linked to LINKFLAGS
the module it self is not linked with the library!
cxxshlib .....
runner ['/usr/bin/g++', '-Wl,--soname=libns3-dev-symphony-debug.so', '-shared', '-pthread', 'src/symphony/model/tos-to-ns3-proxy.cc.1.o', 'src/symphony/model/ns3-to-tos-proxy_auto.cc.1.o', 'src/symphony/model/tos-node-list.cc.1.o', 'src/symphony/model/tos-mac-low.cc.1.o', 'src/symphony/model/tos-net-device.cc.1.o', 'src/symphony/helper/tos-node-container.cc.1.o', 'src/symphony/helper/tos-helper.cc.1.o', 'src/symphony/helper/yans-tos-helper.cc.1.o', 'src/symphony/helper/tos-net-device-container.cc.1.o', 'src/symphony/helper/tos-mobility-helper.cc.1.o', 'src/symphony/helper/symphony-xml.cc.1.o', 'src/symphony/helper/practical-socket.cc.1.o', 'src/symphony/model/tos-node.cc.1.o', 'src/symphony/model/simu-clock.cc.1.o', 'src/symphony/model/RF230-radio-model.cc.1.o', 'src/symphony/model/tos-radio-model.cc.1.o', 'src/symphony/model/model-vocabulary.cc.1.o', 'src/symphony/model/model-element.cc.1.o', 'src/symphony/model/hardware-model.cc.1.o', '-o', '/home/dev/ns-3/ns-3-allinone/ns-3-dev/build/libns3-dev-symphony-debug.so', '-Wl,-Bstatic', '-Wl,-Bdynamic', '-L.', '-L.', '-L.', '-L.', '-L.', '-lns3-dev-wifi-debug', '-lns3-dev-propagation-debug', '-lns3-dev-mobility-debug', '-lns3-dev-network-debug', '-lns3-dev-core-debug', '-lrt', '-lgsl', '-lgslcblas', '-lm']

no -lxerces-c!
ldd yields not existence and build fails.
When compiling "manually"
/usr/bin/g++ -Wl--soname=libns3-dev-symphony-debug.so -shared -pthread src/symphony/model/tos-to-ns3-proxy.cc.1.o src/symphony/model/ns3-to-tos-proxy_auto.cc.1.o src/symphony/model/tos-node-list.cc.1.o src/symphony/model/tos-mac-low.cc.1.o src/symphony/model/tos-net-device.cc.1.o src/symphony/helper/tos-node-container.cc.1.o src/symphony/helper/tos-helper.cc.1.o src/symphony/helper/yans-tos-helper.cc.1.o src/symphony/helper/tos-net-device-container.cc.1.o src/symphony/helper/tos-mobility-helper.cc.1.o src/symphony/helper/symphony-xml.cc.1.o src/symphony/helper/practical-socket.cc.1.o src/symphony/model/tos-node.cc.1.o src/symphony/model/simu-clock.cc.1.o src/symphony/model/RF230-radio-model.cc.1.o src/symphony/model/tos-radio-model.cc.1.o src/symphony/model/model-vocabulary.cc.1.o src/symphony/model/model-element.cc.1.o src/symphony/model/hardware-model.cc.1.o -o /home/lauril/dev/ns-3/ns-3-allinone/ns-3-dev/build/libns3-dev-symphony-debug.so -Wl-Bstatic -Wl-Bdynamic -L. -L. -L. -L. -L. -lns3-dev-wifi-debug -lns3-dev-propagation-debug -lns3-dev-mobility-debug -lns3-dev-network-debug -lns3-dev-core-debug -lrt -lgsl -lgslcblas -lm -lxerces-c

both ldd and me are happy and ns3 can finish build.

Regards!
Comment 1 Laurynas Riliskis 2012-08-24 04:08:26 EDT
I solved the problem http://shieldroute.blogspot.se/2012/08/extending-ns3-with-your-module-and.html

However, I am still unsure if the behaviour described above and in http://www.nsnam.org/wiki/index.php/HOWTO_use_ns-3_with_other_libraries is correct. According to the wiki it should be sufficient to add the LINKFLAG but that only compiles individual object with the flag it do not link module with libraries. Which it should?
Comment 2 Tom Henderson 2012-08-24 11:32:31 EDT
(In reply to comment #1)
> I solved the problem
> http://shieldroute.blogspot.se/2012/08/extending-ns3-with-your-module-and.html
> 
> However, I am still unsure if the behaviour described above and in
> http://www.nsnam.org/wiki/index.php/HOWTO_use_ns-3_with_other_libraries is
> correct. According to the wiki it should be sufficient to add the LINKFLAG but
> that only compiles individual object with the flag it do not link module with
> libraries. Which it should?

Laurynas, sorry this was a headache for you.  We'll look at waf changes and update the documentation; in the meantime, I edited the wiki to point new readers to your blog post until things are fixed.
Comment 3 Tom Henderson 2012-08-26 16:29:01 EDT
Marking down severity; will update documentation along these lines:


================================
While before this would work, 

   module.env['LINKFLAGS'] = '-lfoo'

Now you have to do this:

def configure(conf):
    conf.env['LINKFLAGS_FOO'] = '-lfoo'
...
def build(bld):
   ...
  module = bld.create_ns3_module(...)
   # say we need to "use" the FOO library
   module.use.append('FOO') 

==============================
Comment 4 Rohit 2013-10-14 22:39:30 EDT
Created attachment 1679 [details]
wscript file from ns-3.18 main directory

wscript file from ns-3.18 main directory
Comment 5 Rohit 2013-10-14 22:40:28 EDT
Created attachment 1680 [details]
wscript file from ns-3.18/src/lte directory

wscript file from ns-3.18/src/lte directory
Comment 6 Rohit 2013-10-14 22:42:31 EDT
Created attachment 1681 [details]
lena-simple.cc in ns-3.18/src/lte/examples directory

lena-simple.cc in ns-3.18/src/lte/examples directory.

This is the main file that contains code to boost serialization library
Comment 7 Rohit 2013-10-14 22:51:29 EDT
Hi Tom,

I am trying to compile ns-3.18 with boost serialization library. I followed your instructions in last comment and did following. I made changes in wscript file in ns3.18 main directory by inserting lines below.

conf.env['LINKFLAGS_BOOST_SERIALIZATION'] = '-lboost_serialization'
env.append_value('LINKFLAGS', '-lboost_serialization')

I also modified wscript file in ns-3.18/src/lte directory and added these lines at 
 module.use.extend(['BOOST_SERIALIZATION'])
 module_test.use.extend(['BOOST_SERIALIZATION'])

The code for boost serilization library is in ns-3.18/src/lte/examples/lena-simple.cc

I have also attached all the three files so you can reproduce the problem on a fresh ns-3.18 repository.

Any help from you will be much appreciated.

Regards,
Rohit
P.S. Here is an excerpt of error from build system
usr/include/boost/archive/basic_text_iprimitive.hpp:93: undefined reference to `boost::archive::archive_exception::archive_exception(boost::archive::archive_exception::exception_code, char const*, char const*)'
/usr/include/boost/archive/basic_text_iprimitive.hpp:93: undefined reference to `boost::archive::archive_exception::~archive_exception()'
/usr/include/boost/archive/basic_text_iprimitive.hpp:93: undefined reference to `boost::archive::archive_exception::~archive_exception()'
collect2: ld returned 1 exit status
Waf: Leaving directory `/home/user/Downloads/TestBoostBuild/ns-allinone-3.18/ns-3.18/build'
Build failed
 -> task in 'lena-simple' failed (exit status 1): 
	{task 33965072: cxxprogram lena-simple.cc.10.o -> ns3.18-lena-simple-debug}
['/usr/bin/g++', '-lboost_serialization', '-pthread', '-pthread', '-lboost_serialization', 'src/lte/examples/lena-simple.cc.10.o', '-o', '/home/user/Downloads/TestBoostBuild/ns-allinone-3.18/ns-3.18/build/src/lte/examples/ns3.18-lena-simple-debug', '-Wl,-Bstatic', '-Wl,-Bdynamic', '-Wl,--no-as-needed', '-L.', '-L.', '-L.', '-L.', '-L.', '-L.', '-L.', '-L.', '-L.', '-L.', '-L.', '-L.', '-L.', '-L.', '-L.', '-L.', '-L.', '-lns3.18-lte-debug', '-lns3.18-spectrum-debug', '-lns3.18-csma-debug', '-lns3.18-applications-debug', '-lns3.18-virtual-net-device-debug', '-lns3.18-internet-debug', '-lns3.18-bridge-debug', '-lns3.18-point-to-point-debug', '-lns3.18-mpi-debug', '-lns3.18-buildings-debug', '-lns3.18-propagation-debug', '-lns3.18-mobility-debug', '-lns3.18-config-store-debug', '-lns3.18-network-debug', '-lns3.18-stats-debug', '-lns3.18-antenna-debug', '-lns3.18-core-debug', '-lrt', '-lsqlite3', '-lgtk-x11-2.0', '-lgdk-x11-2.0', '-latk-1.0', '-lgio-2.0', '-lpangoft2-1.0', '-lpangocairo-1.0', '-lgdk_pixbuf-2.0', '-lcairo', '-lpango-1.0', '-lfreetype', '-lfontconfig', '-lgobject-2.0', '-lglib-2.0', '-lxml2']
Comment 8 Rohit 2013-10-15 08:59:41 EDT
Hi there,

Okay now I found the problem, but still someone needs to help me with the solution.

Looking at the log when build fails, this is what happens.

Build failed
 -> task in 'lena-simple' failed (exit status 1): 
    {task 33965072: cxxprogram lena-simple.cc.10.o -> ns3.18-lena-simple-debug}
['/usr/bin/g++', '-lboost_serialization', '-pthread', '-pthread',
'-lboost_serialization', 'src/lte/examples/lena-simple.cc.10.o', '-o',
'/home/user/Downloads/TestBoostBuild/ns-allinone-3.18/ns-3.18/build/src/lte/examples/ns3.18-lena-simple-debug',
'-Wl,-Bstatic', '-Wl,-Bdynamic', '-Wl,--no-as-needed', '-L.', '-L.', '-L.',
'-L.', '-L.', '-L.', '-L.', '-L.', '-L.', '-L.', '-L.', '-L.', '-L.', '-L.',
'-L.', '-L.', '-L.', '-lns3.18-lte-debug', '-lns3.18-spectrum-debug',
'-lns3.18-csma-debug', '-lns3.18-applications-debug',
'-lns3.18-virtual-net-device-debug', '-lns3.18-internet-debug',
'-lns3.18-bridge-debug', '-lns3.18-point-to-point-debug', '-lns3.18-mpi-debug',
'-lns3.18-buildings-debug', '-lns3.18-propagation-debug',
'-lns3.18-mobility-debug', '-lns3.18-config-store-debug',
'-lns3.18-network-debug', '-lns3.18-stats-debug', '-lns3.18-antenna-debug',
'-lns3.18-core-debug', '-lrt', '-lsqlite3', '-lgtk-x11-2.0', '-lgdk-x11-2.0',
'-latk-1.0', '-lgio-2.0', '-lpangoft2-1.0', '-lpangocairo-1.0',
'-lgdk_pixbuf-2.0', '-lcairo', '-lpango-1.0', '-lfreetype', '-lfontconfig',
'-lgobject-2.0', '-lglib-2.0', '-lxml2']

It is strange that even though I have included -lboost_serialization, g++ complains that it cant find boost libraries.

However, if I add '-lboost_serialization' at the end of the list, the compilation works fine if I compile manually!!!
So, if I do something like,

['/usr/bin/g++',  '-pthread', '-pthread',
'-lboost_serialization', 'src/lte/examples/lena-simple.cc.10.o', '-o',
'/home/user/Downloads/TestBoostBuild/ns-allinone-3.18/ns-3.18/build/src/lte/examples/ns3.18-lena-simple-debug',
'-Wl,-Bstatic', '-Wl,-Bdynamic', '-Wl,--no-as-needed', '-L.', '-L.', '-L.',
'-L.', '-L.', '-L.', '-L.', '-L.', '-L.', '-L.', '-L.', '-L.', '-L.', '-L.',
'-L.', '-L.', '-L.', '-lns3.18-lte-debug', '-lns3.18-spectrum-debug',
'-lns3.18-csma-debug', '-lns3.18-applications-debug',
'-lns3.18-virtual-net-device-debug', '-lns3.18-internet-debug',
'-lns3.18-bridge-debug', '-lns3.18-point-to-point-debug', '-lns3.18-mpi-debug',
'-lns3.18-buildings-debug', '-lns3.18-propagation-debug',
'-lns3.18-mobility-debug', '-lns3.18-config-store-debug',
'-lns3.18-network-debug', '-lns3.18-stats-debug', '-lns3.18-antenna-debug',
'-lns3.18-core-debug', '-lrt', '-lsqlite3', '-lgtk-x11-2.0', '-lgdk-x11-2.0',
'-latk-1.0', '-lgio-2.0', '-lpangoft2-1.0', '-lpangocairo-1.0',
'-lgdk_pixbuf-2.0', '-lcairo', '-lpango-1.0', '-lfreetype', '-lfontconfig',
'-lgobject-2.0', '-lglib-2.0', '-lxml2','-lboost_serialization',]


Any help on how I add '-boost_serialization' at the end of list of link flags??

Regards,
Rohit
Comment 9 Peter Barnes 2019-11-05 18:14:28 EST
Is this a documentation bug?  or build-system?