onnxruntime: [Build] Failure to build with shared library flatbuffers 23.3.3
Describe the issue
Trying to build main on Arch Linux fails because Arch Linux packages flatbuffers as a shared library. The flatbuffers target then becomes flatbuffers::flatbuffers_shared, not flatbuffers::flatbuffers as is used in onnxruntime. As a result, CMake fails to find the target.
Replacing flatbuffers::flatbuffers with flatbuffers::flatbuffers_shared makes it pass the CMake stage, but fails to build as well:
onnxruntime/onnxruntime/core/flatbuffers/schema/ort.fbs.h: In member function ‘bool onnxruntime::fbs::DimensionValue::Verify(flatbuffers::Verifier&) const’:
onnxruntime/onnxruntime/core/flatbuffers/schema/ort.fbs.h:553:31: error: no matching function for call to ‘onnxruntime::fbs::DimensionValue::VerifyField<int8_t>(flatbuffers::Verifier&, onnxruntime::fbs::DimensionValue::FlatBuffersVTableOffset) const’
553 | VerifyField<int8_t>(verifier, VT_DIM_TYPE) &&
| ~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/flatbuffers/flatbuffer_builder.h:33,
from /usr/include/flatbuffers/flatbuffers.h:29,
from onnxruntime/onnxruntime/core/flatbuffers/schema/ort.fbs.h:7:
/usr/include/flatbuffers/table.h:115:8: note: candidate: ‘template<class T> bool flatbuffers::Table::VerifyField(const flatbuffers::Verifier&, flatbuffers::voffset_t, size_t) const’
115 | bool VerifyField(const Verifier &verifier, voffset_t field,
| ^~~~~~~~~~~
/usr/include/flatbuffers/table.h:115:8: note: candidate expects 3 arguments, 2 provided
There’s many more errors like this, possibly because of API changes?
Considering flatbuffers is designed as a header-only library, maybe it makes sense to include it as a submodule in this repository, same as protobuf?
Urgency
No response
Target platform
x86_64
Build script
./build.sh --config RelWithDebInfo --build_shared_lib --parallel
Error / output
CMake Error at onnxruntime_flatbuffers.cmake:18 (add_dependencies):
The dependency target "flatbuffers::flatbuffers" of target
"onnxruntime_flatbuffers" does not exist.
Call Stack (most recent call first):
CMakeLists.txt:1584 (include)
CMake Error at onnxruntime_common.cmake:120 (add_dependencies):
The dependency target "flatbuffers::flatbuffers" of target
"onnxruntime_common" does not exist.
Call Stack (most recent call first):
CMakeLists.txt:1584 (include)
CMake Error at onnxruntime_graph.cmake:89 (add_dependencies):
The dependency target "flatbuffers::flatbuffers" of target
"onnxruntime_graph" does not exist.
Call Stack (most recent call first):
CMakeLists.txt:1584 (include)
CMake Error at onnxruntime_framework.cmake:100 (add_dependencies):
The dependency target "flatbuffers::flatbuffers" of target
"onnxruntime_framework" does not exist.
Call Stack (most recent call first):
CMakeLists.txt:1584 (include)
CMake Error at onnxruntime_util.cmake:19 (add_dependencies):
The dependency target "flatbuffers::flatbuffers" of target
"onnxruntime_util" does not exist.
Call Stack (most recent call first):
CMakeLists.txt:1584 (include)
CMake Error at onnxruntime_providers.cmake:284 (add_dependencies):
The dependency target "flatbuffers::flatbuffers" of target
"onnxruntime_providers" does not exist.
Call Stack (most recent call first):
CMakeLists.txt:1584 (include)
CMake Error at onnxruntime_optimizer.cmake:106 (add_dependencies):
The dependency target "flatbuffers::flatbuffers" of target
"onnxruntime_optimizer" does not exist.
Call Stack (most recent call first):
CMakeLists.txt:1584 (include)
CMake Error at onnxruntime_session.cmake:46 (add_dependencies):
The dependency target "flatbuffers::flatbuffers" of target
"onnxruntime_session" does not exist.
Call Stack (most recent call first):
CMakeLists.txt:1584 (include)
CMake Error at onnxruntime.cmake:100 (add_dependencies):
The dependency target "flatbuffers::flatbuffers" of target "onnxruntime"
does not exist.
Call Stack (most recent call first):
CMakeLists.txt:1584 (include)
CMake Error at onnxruntime_unittests.cmake:695 (add_dependencies):
The dependency target "flatbuffers::flatbuffers" of target
"onnxruntime_test_utils" does not exist.
Call Stack (most recent call first):
CMakeLists.txt:1584 (include)
CMake Error at onnxruntime_unittests.cmake:723 (add_dependencies):
The dependency target "flatbuffers::flatbuffers" of target
"onnx_test_runner_common" does not exist.
Call Stack (most recent call first):
CMakeLists.txt:1584 (include)
CMake Error at onnxruntime_unittests.cmake:47 (add_dependencies):
The dependency target "flatbuffers::flatbuffers" of target
"onnxruntime_test_all" does not exist.
Call Stack (most recent call first):
onnxruntime_unittests.cmake:798 (AddTest)
CMakeLists.txt:1584 (include)
CMake Error at onnxruntime_unittests.cmake:859 (add_dependencies):
The dependency target "flatbuffers::flatbuffers" of target
"onnx_test_data_proto" does not exist.
Call Stack (most recent call first):
CMakeLists.txt:1584 (include)
CMake Error at onnxruntime_unittests.cmake:47 (add_dependencies):
The dependency target "flatbuffers::flatbuffers" of target
"onnxruntime_shared_lib_test" does not exist.
Call Stack (most recent call first):
onnxruntime_unittests.cmake:1251 (AddTest)
CMakeLists.txt:1584 (include)
CMake Error at onnxruntime_unittests.cmake:47 (add_dependencies):
The dependency target "flatbuffers::flatbuffers" of target
"onnxruntime_global_thread_pools_test" does not exist.
Call Stack (most recent call first):
onnxruntime_unittests.cmake:1276 (AddTest)
CMakeLists.txt:1584 (include)
CMake Error at onnxruntime_unittests.cmake:47 (add_dependencies):
The dependency target "flatbuffers::flatbuffers" of target
"onnxruntime_api_tests_without_env" does not exist.
Call Stack (most recent call first):
onnxruntime_unittests.cmake:1286 (AddTest)
CMakeLists.txt:1584 (include)
CMake Error at onnxruntime_unittests.cmake:47 (add_dependencies):
The dependency target "flatbuffers::flatbuffers" of target
"onnxruntime_customopregistration_test" does not exist.
Call Stack (most recent call first):
onnxruntime_unittests.cmake:1510 (AddTest)
CMakeLists.txt:1584 (include)
CMake Error at onnxruntime.cmake:211 (target_link_libraries):
Target "onnxruntime" links to:
flatbuffers::flatbuffers
but the target was not found. Possible reasons include:
* There is a typo in the target name.
* A find_package call is missing for an IMPORTED target.
* An ALIAS target is missing.
Call Stack (most recent call first):
CMakeLists.txt:1584 (include)
CMake Error at onnxruntime_unittests.cmake:55 (target_link_libraries):
Target "onnxruntime_test_all" links to:
flatbuffers::flatbuffers
but the target was not found. Possible reasons include:
* There is a typo in the target name.
* A find_package call is missing for an IMPORTED target.
* An ALIAS target is missing.
Call Stack (most recent call first):
onnxruntime_unittests.cmake:798 (AddTest)
CMakeLists.txt:1584 (include)
CMake Error at onnxruntime_unittests.cmake:1002 (target_link_libraries):
Target "onnx_test_runner" links to:
flatbuffers::flatbuffers
but the target was not found. Possible reasons include:
* There is a typo in the target name.
* A find_package call is missing for an IMPORTED target.
* An ALIAS target is missing.
Call Stack (most recent call first):
CMakeLists.txt:1584 (include)
CMake Error at onnxruntime_unittests.cmake:1203 (target_link_libraries):
Target "onnxruntime_perf_test" links to:
flatbuffers::flatbuffers
but the target was not found. Possible reasons include:
* There is a typo in the target name.
* A find_package call is missing for an IMPORTED target.
* An ALIAS target is missing.
Call Stack (most recent call first):
CMakeLists.txt:1584 (include)
-- Generating done
Visual Studio Version
No response
GCC / Compiler Version
No response
About this issue
- Original URL
- State: open
- Created a year ago
- Comments: 21 (7 by maintainers)
Commits related to this issue
- Try avoid compile bug https://github.com/microsoft/onnxruntime/issues/14981#issuecomment-1497092095 — committed to cms-externals/onnxruntime by smuzaffar a year ago
- Try avoid compile bug https://github.com/microsoft/onnxruntime/issues/14981#issuecomment-1497092095 (#9) — committed to cms-externals/onnxruntime by smuzaffar a year ago
- Workaround for GCC 12 (#9) See https://github.com/microsoft/onnxruntime/issues/14981#issuecomment-1497253686 . — committed to cms-externals/onnxruntime by smuzaffar a year ago
1.15.0 is out, and now start build failure with flatbuffers 23.5.26
a little snip. the full log generate 3.7Mg of log with -j1
I was able to build v1.14.1 with the following change