onnxruntime icon indicating copy to clipboard operation
onnxruntime copied to clipboard

Duplicate define operater<<

Open basbaba opened this issue 2 years ago • 1 comments

Describe the bug There is a duplicate define to: namespace ONNX_NAMESPACE { std::ostream& operator<<(std::ostream& os, const TensorShapeProto& shape);} in both: onnxruntime/cmake/external/onnx/onnx/defs/printer.h and: onnxruntime/onnxruntime/core/framework/utils.h

after: ./build.sh --android ... It generates libonnx.a and libonnxruntime_framework.a without any problem. But when I try to load these generated libraries into an android ndk project, the linker will report an error like this:

ld: error: duplicate symbol: onnx::operator<<(std::__ndk1::basic_ostream<char, std::__ndk1::char_traits >&, onnx::TensorShapeProto const&)

defined at printer.cc printer.cc.o:(onnx::operator<<(std::__ndk1::basic_ostream<char, std::__ndk1::char_traits >&, onnx::TensorShapeProto const&)) in archive /xxx/onnxruntime/build/Android/Release/external/onnx/libonnx.a defined at utils.cc utils.cc.o:(.text._ZN4onnxlsERNSt6__ndk113basic_ostreamIcNS0_11char_traitsIcEEEERKNS_16TensorShapeProtoE+0x1) in archive /xxx/onnxruntime/build/Android/Release/libonnxruntime_framework.a

basbaba avatar Jun 16 '22 05:06 basbaba

This is most likely due to a recent addition of printer.h/cc to the ONNX library: https://github.com/onnx/onnx/pull/4246

@gramalingam does the ORT version of the ostream operator<< for TensorShapeProto need to be removed or is there a way for the two versions to co-exist when the static onnx and ORT libraries are used?

skottmckay avatar Aug 11 '22 08:08 skottmckay

Should be addressed by #12651 which will be included in the next ORT release.

skottmckay avatar Aug 22 '22 23:08 skottmckay