Linking error when using FlowMonitorHelper

101 views
Skip to first unread message

Dexin Wang

unread,
May 15, 2019, 7:40:45 PM5/15/19
to ns-3-users
Hello,

I am trying to use the flow monitor in my ns3 script. The *.cc script compiles with no error. However, the linker gives me the following errors:

scratch/TDC-test/TDC-test.cc.1.o: In function `main':
/home/dwang/workspace/bake/source/ns-3.29/build/../scratch/TDC-test/TDC-test.cc:624: undefined reference to `ns3::FlowMonitorHelper::FlowMonitorHelper()'
/home/dwang/workspace/bake/source/ns-3.29/build/../scratch/TDC-test/TDC-test.cc:625: undefined reference to `ns3::FlowMonitorHelper::InstallAll()'
/home/dwang/workspace/bake/source/ns-3.29/build/../scratch/TDC-test/TDC-test.cc:628: undefined reference to `ns3::FlowMonitor::SerializeToXmlFile(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool, bool)'
/home/dwang/workspace/bake/source/ns-3.29/build/../scratch/TDC-test/TDC-test.cc:624: undefined reference to `ns3::FlowMonitorHelper::~FlowMonitorHelper()'
/home/dwang/workspace/bake/source/ns-3.29/build/../scratch/TDC-test/TDC-test.cc:624: undefined reference to `ns3::FlowMonitorHelper::~FlowMonitorHelper()'
collect2: error: ld returned 1 exit status

As you can see, I put the script under the scratch directory, so there shouldn't be any problem with dependencies. And I checked the build/lib/ directory, the *.so file is there.
.../ns-3.29$ ls build/lib/libns3-dev-flow-*
build/lib/libns3-dev-flow-monitor-debug.so

Could anyone help me figure out how to fix this problem?

Thanks,
Dexin

Tom Henderson

unread,
May 15, 2019, 8:57:50 PM5/15/19
to ns-3-...@googlegroups.com

I don't know offhand; I am able to include flow monitor in scratch programs.

Is 'flow-monitor' one of the listed modules under Modules built: when you build with waf?  You haven't restricted scope on your build but left old libraries around in your build directory?

If you want to see exactly how the linker is invoked, you can type './waf build -v'

- Tom



Dexin Wang

unread,
May 16, 2019, 2:16:36 PM5/16/19
to ns-3-users
Hi Tom,

Thank you so much for looking into it.

I tried './waf build -v' as you suggested.

[1917/1994] Linking build/scratch/TDC-test/ns3-dev-TDC-test-debug
11:08:46 runner ['/usr/bin/g++', '-pthread', 'scratch/TDC-test/TDC-test.cc.1.o', '-o/home/dwang/workspace/bake/source/ns-3.29/build/scratch/TDC-test/ns3-dev-TDC-test-debug', '-Wl,-Bstatic', '-Wl,-Bdynamic', '-Wl,--no-as-needed', '-Llib', '-lyaml-cpp', '-lns3-dev-netanim-debug', '-lns3-dev-wimax-debug', '-lns3-dev-lte-debug', '-lns3-dev-applications-debug', '-lns3-dev-wave-debug', '-lns3-dev-point-to-point-layout-debug', '-lns3-dev-internet-debug', '-lns3-dev-bridge-debug', '-lns3-dev-point-to-point-debug', '-lns3-dev-mpi-debug', '-lns3-dev-traffic-control-debug', '-lns3-dev-wifi-debug', '-lns3-dev-lr-wpan-debug', '-lns3-dev-spectrum-debug', '-lns3-dev-buildings-debug', '-lns3-dev-propagation-debug', '-lns3-dev-uan-debug', '-lns3-dev-mobility-debug', '-lns3-dev-energy-debug', '-lns3-dev-csma-debug', '-lns3-dev-config-store-debug', '-lns3-dev-virtual-net-device-debug', '-lns3-dev-fd-net-device-debug', '-lns3-dev-network-debug', '-lns3-dev-stats-debug', '-lns3-dev-antenna-debug', '-lns3-dev-core-debug', '-lrt', '-lgsl', '-lgslcblas', '-lm', '-lsqlite3', '-lxml2']
scratch/TDC-test/TDC-test.cc.1.o: In function `main':
/home/dwang/workspace/bake/source/ns-3.29/build/../scratch/TDC-test/TDC-test.cc:624: undefined reference to `ns3::FlowMonitorHelper::FlowMonitorHelper()'
/home/dwang/workspace/bake/source/ns-3.29/build/../scratch/TDC-test/TDC-test.cc:625: undefined reference to `ns3::FlowMonitorHelper::InstallAll()'
/home/dwang/workspace/bake/source/ns-3.29/build/../scratch/TDC-test/TDC-test.cc:628: undefined reference to `ns3::FlowMonitor::SerializeToXmlFile(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool, bool)'
/home/dwang/workspace/bake/source/ns-3.29/build/../scratch/TDC-test/TDC-test.cc:624: undefined reference to `ns3::FlowMonitorHelper::~FlowMonitorHelper()'
/home/dwang/workspace/bake/source/ns-3.29/build/../scratch/TDC-test/TDC-test.cc:624: undefined reference to `ns3::FlowMonitorHelper::~FlowMonitorHelper()'
collect2: error: ld returned 1 exit status

It looks like 'flow-monitor' is not among the linked libraries. However, when I build after removing lines related to flow-monitor, it does show up in the Modules built list.

Modules built:
antenna                   aodv                      applications
bridge                    buildings                 config-store
core                      csma                      csma-layout
dsdv                      dsr                       energy
fd-net-device             flow-monitor              internet
internet-apps             lr-wpan                   lte
mesh                      mobility                  mpi
netanim (no Python)       network                   nix-vector-routing
olsr                      point-to-point            point-to-point-layout
propagation               sixlowpan                 spectrum
stats                     tap-bridge                test (no Python)
topology-read             traffic-control           uan
virtual-net-device        visualizer                wave
wifi                      wimax

Modules not built (see ns-3 tutorial for explanation):
brite                     click                     openflow

How can I fix this problem?

Thanks,
Dexin

Dexin Wang

unread,
May 30, 2019, 2:04:20 PM5/30/19
to ns-3-users
I just realized that there are more error/warning messages before the linking happens. I got a ton of "Erroneous order constraint ..." messages like

Erroneous order constraint 'after'='link' on task class 'print_introspected_doxygen_task'
Erroneous order constraint 'after'='link' on task class 'run_python_unit_tests_task'
Erroneous order constraint 'after'='link' on task class 'SuidBuild_task'
Erroneous order constraint 'before' on non-rule based task generator bld(posted=True, target=['bindings/ns3module.cc', 'bindings/ns3module.h', 'bindings/ns3modulegen.log'], idx=6, dep_vars=['FEATURES', 'GCC_RTTI_ABI_COMPLETE'], tg_idx_count=6, meths=['check_err_features', 'check_err_order', 'collect_compilation_db_tasks', 'init_command', 'process_rule', 'apply_command', 'process_source'], install_path=None, _name='pybindgen(ns3 module antenna)', source=[/home/developer/ns-allinone-3.29/ns-3.29/bindings/python/ns3modulegen-modular.py, /home/developer/ns-allinone-3.29/ns-3.29/src/antenna/bindings/modulegen__gcc_LP64.py], command=['NS3_ENABLED_FEATURES=${FEATURES}', 'GCC_RTTI_ABI_COMPLETE=${GCC_RTTI_ABI_COMPLETE}', '${PYTHON}', '${SRC[0]}', '/home/developer/ns-allinone-3.29/ns-3.29/src/antenna', 'gcc_LP64', 'antenna', '${TGT[0]}', '2>', '${TGT[2]}'], path=/home/developer/ns-allinone-3.29/ns-3.29/src/antenna, before='cxx', after='gen_ns3_module_header', features=['command']) in /home/developer/ns-allinone-3.29/ns-3.29/src/antenna

...

Do these messages shed some light on this problem?

Thanks,
Dexin

Tom Henderson

unread,
May 30, 2019, 5:07:41 PM5/30/19
to ns-3-...@googlegroups.com
On 5/30/19 11:04 AM, Dexin Wang wrote:
I just realized that there are more error/warning messages before the linking happens. I got a ton of "Erroneous order constraint ..." messages like

Erroneous order constraint 'after'='link' on task class 'print_introspected_doxygen_task'
Erroneous order constraint 'after'='link' on task class 'run_python_unit_tests_task'
Erroneous order constraint 'after'='link' on task class 'SuidBuild_task'
Erroneous order constraint 'before' on non-rule based task generator bld(posted=True, target=['bindings/ns3module.cc', 'bindings/ns3module.h', 'bindings/ns3modulegen.log'], idx=6, dep_vars=['FEATURES', 'GCC_RTTI_ABI_COMPLETE'], tg_idx_count=6, meths=['check_err_features', 'check_err_order', 'collect_compilation_db_tasks', 'init_command', 'process_rule', 'apply_command', 'process_source'], install_path=None, _name='pybindgen(ns3 module antenna)', source=[/home/developer/ns-allinone-3.29/ns-3.29/bindings/python/ns3modulegen-modular.py, /home/developer/ns-allinone-3.29/ns-3.29/src/antenna/bindings/modulegen__gcc_LP64.py], command=['NS3_ENABLED_FEATURES=${FEATURES}', 'GCC_RTTI_ABI_COMPLETE=${GCC_RTTI_ABI_COMPLETE}', '${PYTHON}', '${SRC[0]}', '/home/developer/ns-allinone-3.29/ns-3.29/src/antenna', 'gcc_LP64', 'antenna', '${TGT[0]}', '2>', '${TGT[2]}'], path=/home/developer/ns-allinone-3.29/ns-3.29/src/antenna, before='cxx', after='gen_ns3_module_header', features=['command']) in /home/developer/ns-allinone-3.29/ns-3.29/src/antenna

...

Do these messages shed some light on this problem?


I don't think that has any bearing, but you can get rid of the warnings by patching similar to how it was fixed in the mainline a month ago; see:

https://gitlab.com/nsnam/ns-3-dev/commit/5396fc911e1bd06e1bb44fbb9491fce80d8f89ea

- Tom


Reply all
Reply to author
Forward
0 new messages