Open jorgefm opened 2 years ago
I suspect the error, that is:
org::eclipse::cyclonedds::topic::TopicTraits<ShapeType>::type_map_blob' CMakeFiles/cyclone_demo_ishapes.dir/cyclone_demo_ishapes_autogen/mocs_compilation.cpp.o:(.rodata+0x540): first defined here CMakeFiles/cyclone_demo_ishapes.dir/ishape.cpp.o:(.rodata+0x160): multiple definition of org::eclipse::cyclonedds::topic::TopicTraits::type_info_blob'
is caused by the type_map_blob
and type_map_blob_sz
being defined in a header file. There are hacks to make the linker accept this, but it would probably be better to have the definitions in the .cpp
file and only an extern
declaration in the .hpp
file.
@reicheratwork you know the code generated by IDLC C++ backend better than I do. Any reason to think that I am thinking in the wrong direction?
Only just noticed this, sorry everyone.
@jorgefm I think i have the issue nailed down, and it is as @eboasson thought. Having the definition of the template specialization in the header file is a violation of the One Definition Rule as soon as the header is included in more than one compilation unit. You can keep track of the progress of the fix on the following issue on CycloneDDS-CXX: 269 .
Hi, I'm trying to compile the CycloneDDS version in order to communicate with the OpenDDS idhape demo but I get a linking error. I have Ubuntu 18.04 and the last CycloneDDS from github.
The configuring process:
$ cmake .. -DADLINK_DDS_PRODUCT=Cyclone -DCYCLONE_INSTALLED_DIR=/tmp/CycloneDDS/cyclonedds-install -- -DADLINK_DDS_PRODUCT = Cyclone -- -DCYCLONE_INSTALLED_DIR = /tmp/CycloneDDS/cyclonedds-install -- The C compiler identification is GNU 7.5.0 -- The CXX compiler identification is GNU 7.5.0 -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done -- Check for working C compiler: /usr/bin/cc - skipped -- Detecting C compile features -- Detecting C compile features - done -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Check for working CXX compiler: /usr/bin/c++ - skipped -- Detecting CXX compile features -- Detecting CXX compile features - done -- Configuring done CMake Warning (dev) in CMakeLists.txt: Policy CMP0071 is not set: Let AUTOMOC and AUTOUIC process GENERATED files. Run "cmake --help-policy CMP0071" for policy details. Use the cmake_policy command to set the policy and suppress this warning.
For compatibility, CMake is excluding the GENERATED source file(s):
from processing by AUTOMOC and AUTOUIC. If any of the files should be processed, set CMP0071 to NEW. If any of the files should not be processed, explicitly exclude them by setting the source file property SKIP_AUTOGEN:
This warning is for project developers. Use -Wno-dev to suppress it.
-- Generating done -- Build files have been written to: /tmp/dds-ishapes/cyclone_demo_ishapes
and when building the code:
$ cmake --build . --config Release --target install [ 4%] Generating ishape.hpp, ishape.cpp No default extensibility provided. For one or more of the aggregated types in the IDL the extensibility is not explicitly set. Currently the default extensibility for these types is 'final', but this may change to 'appendable' in a future release because that is the default in the DDS XTypes specification. [ 4%] Built target ddscxxishape_lib_generate [ 9%] Automatic MOC and UIC for target cyclone_demo_ishapes [ 9%] Built target cyclone_demo_ishapes_autogen [ 14%] Automatic RCC for ishape.qrc [ 19%] Building CXX object CMakeFiles/cyclone_demo_ishapes.dir/cyclone_demo_ishapes_autogen/mocs_compilation.cpp.o [ 23%] Building CXX object CMakeFiles/cyclone_demo_ishapes.dir/BouncingShapeDynamics.cpp.o [ 28%] Building CXX object CMakeFiles/cyclone_demo_ishapes.dir/Circle.cpp.o [ 33%] Building CXX object CMakeFiles/cyclone_demo_ishapes.dir/DDSShapeDynamics.cpp.o [ 38%] Building CXX object CMakeFiles/cyclone_demo_ishapes.dir/FilterDialog.cpp.o [ 42%] Building CXX object CMakeFiles/cyclone_demo_ishapes.dir/ReaderQosDialog.cpp.o [ 47%] Building CXX object CMakeFiles/cyclone_demo_ishapes.dir/Shape.cpp.o [ 52%] Building CXX object CMakeFiles/cyclone_demo_ishapes.dir/ShapeDynamics.cpp.o [ 57%] Building CXX object CMakeFiles/cyclone_demo_ishapes.dir/ShapesDialog.cpp.o [ 61%] Building CXX object CMakeFiles/cyclone_demo_ishapes.dir/ShapesWidget.cpp.o [ 66%] Building CXX object CMakeFiles/cyclone_demo_ishapes.dir/Square.cpp.o [ 71%] Building CXX object CMakeFiles/cyclone_demo_ishapes.dir/Triangle.cpp.o [ 76%] Building CXX object CMakeFiles/cyclone_demo_ishapes.dir/WriterQosDialog.cpp.o [ 80%] Building CXX object CMakeFiles/cyclone_demo_ishapes.dir/main.cpp.o [ 85%] Building CXX object CMakeFiles/cyclone_demo_ishapes.dir/cyclone_demo_ishapes_autogen/EWIEGA46WW/qrc_ishape.cpp.o [ 90%] Building CXX object CMakeFiles/cyclone_demo_ishapes.dir/ishape.cpp.o [ 95%] Linking CXX executable cyclone_demo_ishapes CMakeFiles/cyclone_demo_ishapes.dir/BouncingShapeDynamics.cpp.o:(.rodata+0x54): multiple definition of::type_info_blob_sz'
CMakeFiles/cyclone_demo_ishapes.dir/cyclone_demo_ishapes_autogen/mocs_compilation.cpp.o:(.rodata+0x530): first defined here
CMakeFiles/cyclone_demo_ishapes.dir/BouncingShapeDynamics.cpp.o:(.rodata+0x60): multiple definition of ::type_info_blob'
CMakeFiles/cyclone_demo_ishapes.dir/cyclone_demo_ishapes_autogen/mocs_compilation.cpp.o:(.rodata+0x680): first defined here
CMakeFiles/cyclone_demo_ishapes.dir/DDSShapeDynamics.cpp.o:(.rodata+0x5c): multiple definition of ::type_info_blob_sz'
CMakeFiles/cyclone_demo_ishapes.dir/cyclone_demo_ishapes_autogen/mocs_compilation.cpp.o:(.rodata+0x530): first defined here
CMakeFiles/cyclone_demo_ishapes.dir/DDSShapeDynamics.cpp.o:(.rodata+0x80): multiple definition of ::type_info_blob'
CMakeFiles/cyclone_demo_ishapes.dir/cyclone_demo_ishapes_autogen/mocs_compilation.cpp.o:(.rodata+0x680): first defined here
CMakeFiles/cyclone_demo_ishapes.dir/ShapesDialog.cpp.o:(.rodata+0x8f0): multiple definition of ::type_info_blob_sz'
CMakeFiles/cyclone_demo_ishapes.dir/cyclone_demo_ishapes_autogen/mocs_compilation.cpp.o:(.rodata+0x530): first defined here
CMakeFiles/cyclone_demo_ishapes.dir/ShapesDialog.cpp.o:(.rodata+0x900): multiple definition of ::type_info_blob'
CMakeFiles/cyclone_demo_ishapes.dir/cyclone_demo_ishapes_autogen/mocs_compilation.cpp.o:(.rodata+0x680): first defined here
CMakeFiles/cyclone_demo_ishapes.dir/main.cpp.o:(.rodata+0x5c): multiple definition of ::type_info_blob_sz'
CMakeFiles/cyclone_demo_ishapes.dir/cyclone_demo_ishapes_autogen/mocs_compilation.cpp.o:(.rodata+0x530): first defined here
CMakeFiles/cyclone_demo_ishapes.dir/main.cpp.o:(.rodata+0x80): multiple definition of ::type_info_blob'
CMakeFiles/cyclone_demo_ishapes.dir/cyclone_demo_ishapes_autogen/mocs_compilation.cpp.o:(.rodata+0x680): first defined here
CMakeFiles/cyclone_demo_ishapes.dir/ishape.cpp.o:(.rodata+0x18): multiple definition of ::type_info_blob_sz'
CMakeFiles/cyclone_demo_ishapes.dir/cyclone_demo_ishapes_autogen/mocs_compilation.cpp.o:(.rodata+0x530): first defined here
CMakeFiles/cyclone_demo_ishapes.dir/ishape.cpp.o:(.rodata+0x20): multiple definition of ::type_info_blob'
CMakeFiles/cyclone_demo_ishapes.dir/cyclone_demo_ishapes_autogen/mocs_compilation.cpp.o:(.rodata+0x680): first defined here
collect2: error: ld returned 1 exit status
CMakeFiles/cyclone_demo_ishapes.dir/build.make:358: recipe for target 'cyclone_demo_ishapes' failed
make[2]: [cyclone_demo_ishapes] Error 1
CMakeFiles/Makefile2:111: recipe for target 'CMakeFiles/cyclone_demo_ishapes.dir/all' failed
make[1]: [CMakeFiles/cyclone_demo_ishapes.dir/all] Error 2
Makefile:135: recipe for target 'all' failed
make: *** [all] Error 2
org::eclipse::cyclonedds::topic::TopicTraits<ShapeType>::type_map_blob_sz' CMakeFiles/cyclone_demo_ishapes.dir/cyclone_demo_ishapes_autogen/mocs_compilation.cpp.o:(.rodata+0x52c): first defined here CMakeFiles/cyclone_demo_ishapes.dir/BouncingShapeDynamics.cpp.o:(.rodata+0x58): multiple definition of
org::eclipse::cyclonedds::topic::TopicTraitsorg::eclipse::cyclonedds::topic::TopicTraits<ShapeType>::type_map_blob' CMakeFiles/cyclone_demo_ishapes.dir/cyclone_demo_ishapes_autogen/mocs_compilation.cpp.o:(.rodata+0x540): first defined here CMakeFiles/cyclone_demo_ishapes.dir/BouncingShapeDynamics.cpp.o:(.rodata+0x1a0): multiple definition of
org::eclipse::cyclonedds::topic::TopicTraitsorg::eclipse::cyclonedds::topic::TopicTraits<ShapeType>::type_map_blob_sz' CMakeFiles/cyclone_demo_ishapes.dir/cyclone_demo_ishapes_autogen/mocs_compilation.cpp.o:(.rodata+0x52c): first defined here CMakeFiles/cyclone_demo_ishapes.dir/DDSShapeDynamics.cpp.o:(.rodata+0x60): multiple definition of
org::eclipse::cyclonedds::topic::TopicTraitsorg::eclipse::cyclonedds::topic::TopicTraits<ShapeType>::type_map_blob' CMakeFiles/cyclone_demo_ishapes.dir/cyclone_demo_ishapes_autogen/mocs_compilation.cpp.o:(.rodata+0x540): first defined here CMakeFiles/cyclone_demo_ishapes.dir/DDSShapeDynamics.cpp.o:(.rodata+0x1c0): multiple definition of
org::eclipse::cyclonedds::topic::TopicTraitsorg::eclipse::cyclonedds::topic::TopicTraits<ShapeType>::type_map_blob_sz' CMakeFiles/cyclone_demo_ishapes.dir/cyclone_demo_ishapes_autogen/mocs_compilation.cpp.o:(.rodata+0x52c): first defined here CMakeFiles/cyclone_demo_ishapes.dir/ShapesDialog.cpp.o:(.rodata+0x8f4): multiple definition of
org::eclipse::cyclonedds::topic::TopicTraitsorg::eclipse::cyclonedds::topic::TopicTraits<ShapeType>::type_map_blob' CMakeFiles/cyclone_demo_ishapes.dir/cyclone_demo_ishapes_autogen/mocs_compilation.cpp.o:(.rodata+0x540): first defined here CMakeFiles/cyclone_demo_ishapes.dir/ShapesDialog.cpp.o:(.rodata+0xa40): multiple definition of
org::eclipse::cyclonedds::topic::TopicTraitsorg::eclipse::cyclonedds::topic::TopicTraits<ShapeType>::type_map_blob_sz' CMakeFiles/cyclone_demo_ishapes.dir/cyclone_demo_ishapes_autogen/mocs_compilation.cpp.o:(.rodata+0x52c): first defined here CMakeFiles/cyclone_demo_ishapes.dir/main.cpp.o:(.rodata+0x60): multiple definition of
org::eclipse::cyclonedds::topic::TopicTraitsorg::eclipse::cyclonedds::topic::TopicTraits<ShapeType>::type_map_blob' CMakeFiles/cyclone_demo_ishapes.dir/cyclone_demo_ishapes_autogen/mocs_compilation.cpp.o:(.rodata+0x540): first defined here CMakeFiles/cyclone_demo_ishapes.dir/main.cpp.o:(.rodata+0x1c0): multiple definition of
org::eclipse::cyclonedds::topic::TopicTraitsorg::eclipse::cyclonedds::topic::TopicTraits<ShapeType>::type_map_blob_sz' CMakeFiles/cyclone_demo_ishapes.dir/cyclone_demo_ishapes_autogen/mocs_compilation.cpp.o:(.rodata+0x52c): first defined here CMakeFiles/cyclone_demo_ishapes.dir/ishape.cpp.o:(.rodata+0x1c): multiple definition of
org::eclipse::cyclonedds::topic::TopicTraitsorg::eclipse::cyclonedds::topic::TopicTraits<ShapeType>::type_map_blob' CMakeFiles/cyclone_demo_ishapes.dir/cyclone_demo_ishapes_autogen/mocs_compilation.cpp.o:(.rodata+0x540): first defined here CMakeFiles/cyclone_demo_ishapes.dir/ishape.cpp.o:(.rodata+0x160): multiple definition of
org::eclipse::cyclonedds::topic::TopicTraits