[Ns-developers] New header in src/core fails: duplicate symbols
Tommaso Pecorella
tpecorella at mac.com
Fri Jan 27 01:15:35 PST 2012
Hi,
you don't really want to have one header-only file in a complex built system like ns-3.
The long answer (well, my guess) is:
your header file contains both the declarations and the definitions of the functions, however your compiler isn't doing the right job on putting them all as inline.
As a result, the functions code is compiled in different objects, and when the linker is trying to merge them to make the library, it fails.
> ld: duplicate symbol ns3::Hash32(char const*, unsigned long)in src/core/bindings/module_helpers.cc.8.o and src/core/bindings/ns3module.cc.8.o for architecture x86_64
This might as well be caused by the debugging options, as inline functions aren't really stripped as they are in an optimized build.
Anyway, as a general rule ns-3 coding stile strictly forbids to have definitions and declarations in the header (kinda a pain in the *** sometimes, but there's a reason).
Cheers,
Tommaso
On 27 Jan, 2012,at 02:01 AM, "Barnes, Peter D." <barnes26 at llnl.gov> wrote:
Hello Folks,
I tried to add a header-only file to src/core. I added the file to wscript, but the build fails, log below. ld complains about duplicate symbols in two bindings object files. It's especially odd since the symbol doesn't appear in either source file!
I must have made a mistake so simple only an expert can see it ...
Peter
> cd $NS3/repos/hash && NOCOLOR=yes ./waf --keep build
> Waf: Entering directory .../ns3/repos/hash/build'
> [1316/1316] cxxshlib: build/src/core/bindings/ns3module.cc.8.o build/src/core/bindings/module_helpers.cc.8.o -> build/bindings/python/ns/_core.so
> ld: duplicate symbol ns3::Hash32(char const*, unsigned long)in src/core/bindings/module_helpers.cc.8.o and src/core/bindings/ns3module.cc.8.o for architecture x86_64
> collect2: ld returned 1 exit status
> Waf: Leaving directory `.../ns3/repos/hash/build'
> Build failed
> -> task failed (exit status 1):
> {task 4329823184: cxxshlib ns3module.cc.8.o,module_helpers.cc.8.o -> _core.so}
> ['/usr/bin/g++', '-bundle', '-bundle', '-undefined', 'dynamic_lookup', 'src/core/bindings/ns3module.cc.8.o', 'src/core/bindings/module_helpers.cc.8.o', '-o', '.../ns3/repos/hash/build/bindings/python/ns/_core.so', '-L.', '-L.', '-L.', '-L.', '-L.', '-L.', '-L.', '-L.', '-L.', '-L.', '-L.', '-L.', '-L.', '-L.', '-L.', '-L.', '-L.', '-L.', '-L.', '-L.', '-L.', '-L.', '-L.', '-L.', '-L.', '-L.', '-L.', '-L.', '-L.', '-L.', '-L.', '-L.', '-L/sw/lib/python2.7/config', '-L/sw/lib', '-L/sw/lib', '-L/sw/lib', '-L/sw/lib/python2.7/config', '-lns3-dev-aodv-debug', '-lns3-dev-dsdv-debug', '-lns3-dev-mesh-debug', '-lns3-dev-test-debug', '-lns3-dev-csma-layout-debug', '-lns3-dev-point-to-point-layout-debug', '-lns3-dev-netanim-debug', '-lns3-dev-olsr-debug', '-lns3-dev-csma-debug', '-lns3-dev-lte-debug', '-lns3-dev-wimax-debug', '-lns3-dev-spectrum-debug', '-lns3-dev-applications-debug', '-lns3-dev-virtual-net-device-debug', '-lns3-dev-uan-debug', '-lns3-dev-energy-debug', '-lns3-dev-f!
low-monitor-debug', '-lns3-dev-nix-vector-routing-debug', '-lns3-dev-visualizer-debug', '-lns3-dev-internet-debug', '-lns3-dev-bridge-debug', '-lns3-dev-point-to-point-debug', '-lns3-dev-mpi-debug', '-lns3-dev-wifi-debug', '-lns3-dev-propagation-debug', '-lns3-dev-mobility-debug', '-lns3-dev-config-store-debug', '-lns3-dev-tools-debug', '-lns3-dev-stats-debug', '-lns3-dev-topology-read-debug', '-lns3-dev-network-debug', '-lns3-dev-core-debug', '-lpython2.7', '-lgsl', '-lgslcblas', '-lm', '-lgtk-x11-2.0', '-lgdk-x11-2.0', '-latk-1.0', '-lgio-2.0', '-lpangoft2-1.0', '-lgdk_pixbuf-2.0', '-lpangocairo-1.0', '-lcairo', '-lpango-1.0', '-lfreetype', '-lfontconfig', '-lgobject-2.0', '-lgmodule-2.0', '-lglib-2.0', '-lintl', '-lxml2', '-lsqlite3', '-lpython2.7']
>
> Compilation exited abnormally with code 1 at Thu Jan 26 17:00:00
>
_______________________________________________________________________
Dr. Peter D. Barnes, Jr. Physics Division
Lawrence Livermore National Laboratory Physical and Life Sciences
7000 East Avenue, L-50 email: pdbarnes at llnl.gov
P. O. Box 808 Voice: (925) 422-3384
Livermore, California 94550 Fax: (925) 423-3371
-----------------------------------------------------------------
Tommaso Pecorella - Ph.D.
Assistant professor
Dpt. Elettronica e Telecomunicazioni
Università di Firenze
CNIT - Università di Firenze Unit
via di S. Marta 3
50139, Firenze
ITALY
email: tommaso.pecorella at unifi.it
tommaso.pecorella at cnit.it
phone : +39-055-4796412
mobile: +39-320-4379803
fax : +39-055-494569
More information about the Ns-developers
mailing list