Bugzilla – Bug 1490
module linkflags are dismissed when creating module (cxxshlib)
Last modified: 2019-11-05 18:14:28 EST
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!
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?
(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.
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') ==============================
Created attachment 1679 [details] wscript file from ns-3.18 main directory wscript file from ns-3.18 main directory
Created attachment 1680 [details] wscript file from ns-3.18/src/lte directory wscript file from ns-3.18/src/lte directory
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
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']
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
Is this a documentation bug? or build-system?