-
Notifications
You must be signed in to change notification settings - Fork 556
Closed
Description
Any two .cpp files including the same SBE flyweight won't link.
How to reproduce:
Apply this patch:
diff --git a/sbe-samples/src/main/cpp/CMakeLists.txt b/sbe-samples/src/main/cpp/CMakeLists.txt
index 76bee3f..31fbd49 100644
--- a/sbe-samples/src/main/cpp/CMakeLists.txt
+++ b/sbe-samples/src/main/cpp/CMakeLists.txt
@@ -29,7 +29,7 @@ add_custom_command(
)
add_custom_target(examples_codecs DEPENDS ${GENERATED_CODECS})
-add_executable(GeneratedStubExample GeneratedStubExample.cpp)
+add_executable(GeneratedStubExample GeneratedStubExample.cpp GeneratedStubExample2.cpp)
add_executable(OtfExample OtfExample.cpp)
target_link_libraries(OtfExample sbe)
diff --git a/sbe-samples/src/main/cpp/GeneratedStubExample2.cpp b/sbe-samples/src/main/cpp/GeneratedStubExample2.cpp
new file mode 100644
index 0000000..2153c81
--- /dev/null
+++ b/sbe-samples/src/main/cpp/GeneratedStubExample2.cpp
@@ -0,0 +1,3 @@
+#include "baseline/MessageHeader.h"
+#include "baseline/Car.h"
+
Try and build the C++ samples:
[ 29%] Built target gtest
[ 33%] Built target sbe
[ 37%] Built target codecs
[ 40%] Built target BoundsCheckTest
[ 44%] Built target CodeGenTest
[ 48%] Built target CompositeElementsTest
[ 51%] Built target CompositeOffsetsCodeGenTest
[ 55%] Built target CompositeOffsetsIrTest
[ 59%] Built target GroupWithDataTest
[ 62%] Built target MessageBlockLengthTest
[ 66%] Built target Rc3OtfFullIrTest
[ 70%] Built target examples_codecs
Linking CXX executable ../../../../binaries/GeneratedStubExample
CMakeFiles/GeneratedStubExample.dir/GeneratedStubExample2.cpp.o:(.rodata+0x0): multiple definition of `baseline::Car::SbeSemanticType'
CMakeFiles/GeneratedStubExample.dir/GeneratedStubExample.cpp.o:(.rodata+0x50): first defined here
CMakeFiles/GeneratedStubExample.dir/GeneratedStubExample2.cpp.o:(.rodata+0x2): multiple definition of `baseline::Car::SbeSchemaVersion'
CMakeFiles/GeneratedStubExample.dir/GeneratedStubExample.cpp.o:/home/erigtorp/src/simple-binary-encoding/generated/baseline/MessageHeader.h:48: first defined here
CMakeFiles/GeneratedStubExample.dir/GeneratedStubExample2.cpp.o:(.rodata+0x4): multiple definition of `baseline::Car::SbeSchemaId'
CMakeFiles/GeneratedStubExample.dir/GeneratedStubExample.cpp.o:/home/erigtorp/src/simple-binary-encoding/generated/baseline/MessageHeader.h:48: first defined here
CMakeFiles/GeneratedStubExample.dir/GeneratedStubExample2.cpp.o:(.rodata+0x6): multiple definition of `baseline::Car::SbeTemplateId'
CMakeFiles/GeneratedStubExample.dir/GeneratedStubExample.cpp.o:/home/erigtorp/src/simple-binary-encoding/generated/baseline/MessageHeader.h:48: first defined here
CMakeFiles/GeneratedStubExample.dir/GeneratedStubExample2.cpp.o:(.rodata+0x8): multiple definition of `baseline::Car::SbeBlockLength'
CMakeFiles/GeneratedStubExample.dir/GeneratedStubExample.cpp.o:/home/erigtorp/src/simple-binary-encoding/sbe-samples/src/main/cpp/GeneratedStubExample.cpp:40: first defined here
collect2: error: ld returned 1 exit status
make[2]: *** [binaries/GeneratedStubExample] Error 1
make[1]: *** [sbe-samples/src/main/cpp/CMakeFiles/GeneratedStubExample.dir/all] Error 2
make: *** [all] Error 2
Metadata
Metadata
Assignees
Labels
No labels