C++ library building for Linux in WSL build error for #if __has_include("model-parameters/model_metadata.h")

Question/Issue:
C++ library building for Linux in WSL build error for #if __has_include(“model-parameters/model_metadata.h”)

Project ID:

Steps Taken:

  1. sudo apt update
    sudo apt install build-essentials
  2. Copy main.cpp and makefile from GitHub - edgeimpulse/example-standalone-inferencing: Builds and runs an exported impulse locally (C++)
  3. type make -j4

Expected Outcome:
main.cpp gets compiled and runs inference

Actual Outcome:
main.cpp stops compiling and the error is here

g++ -I. -g -Wno-strict-aliasing -Os -DNDEBUG -DEI_CLASSIFIER_ENABLE_DETECTION_POSTPROCESS_OP -DTF_LITE_DISABLE_X86_NEON=1 -std=c++11 -c source/main.cpp -o source/main.o
In file included from ./edge-impulse-sdk/classifier/ei_model_types.h:42:0,
from ./edge-impulse-sdk/classifier/ei_run_classifier.h:38,
from source/main.cpp:12:
./edge-impulse-sdk/dsp/numpy.hpp:66:18: error: missing binary operator before token “(”
#if __has_include(“model-parameters/model_metadata.h”)
^
In file included from ./edge-impulse-sdk/third_party/flatbuffers/include/flatbuffers/fb_array.h:20:0,
from ./edge-impulse-sdk/third_party/flatbuffers/include/flatbuffers/flatbuffers.h:22,
from ./edge-impulse-sdk/tensorflow/lite/schema/schema_generated.h:4,
from ./edge-impulse-sdk/tensorflow/lite/core/api/flatbuffer_conversions.h:28,
from ./edge-impulse-sdk/tensorflow/lite/micro/micro_mutable_op_resolver.h:22,
from ./edge-impulse-sdk/tensorflow/lite/micro/all_ops_resolver.h:19,
from ./edge-impulse-sdk/classifier/inferencing_engines/tflite_helper.h:52,
from ./edge-impulse-sdk/classifier/inferencing_engines/tflite_eon.h:45,
from ./edge-impulse-sdk/classifier/ei_run_classifier.h:62,
from source/main.cpp:12:
./edge-impulse-sdk/third_party/flatbuffers/include/flatbuffers/fb_base.h:232:22: error: missing binary operator before token “(”
#if __has_include(<string_view>) && (__cplusplus >= 201606 || (defined(_HAS_CXX17) && _HAS_CXX17))
^
./edge-impulse-sdk/third_party/flatbuffers/include/flatbuffers/fb_base.h:239:24: error: missing binary operator before token “(”
#elif __has_include(<experimental/string_view>) && (__cplusplus >= 201411)
^
./edge-impulse-sdk/third_party/flatbuffers/include/flatbuffers/fb_base.h:246:24: error: missing binary operator before token “(”
#elif __has_include(“absl/strings/string_view.h”)
^

Reproducibility:
[ ] Always

Environment:
WSL Ubuntu 22.04.5

  • Platform: Windows 11 running WSL
    Logs/Attachments:
    ^
    g++ -I. -g -Wno-strict-aliasing -Os -DNDEBUG -DEI_CLASSIFIER_ENABLE_DETECTION_POSTPROCESS_OP -DTF_LITE_DISABLE_X86_NEON=1 -std=c++11 -c edge-impulse-sdk/tensorflow/lite/micro/memory_planner/greedy_memory_planner.cc -o edge-impulse-sdk/tensorflow/lite/micro/memory_planner/greedy_memory_planner.o
    g++ -I. -g -Wno-strict-aliasing -Os -DNDEBUG -DEI_CLASSIFIER_ENABLE_DETECTION_POSTPROCESS_OP -DTF_LITE_DISABLE_X86_NEON=1 -std=c++11 -c edge-impulse-sdk/tensorflow/lite/micro/memory_planner/linear_memory_planner.cc -o edge-impulse-sdk/tensorflow/lite/micro/memory_planner/linear_memory_planner.o
    g++ -I. -g -Wno-strict-aliasing -Os -DNDEBUG -DEI_CLASSIFIER_ENABLE_DETECTION_POSTPROCESS_OP -DTF_LITE_DISABLE_X86_NEON=1 -std=c++11 -c edge-impulse-sdk/tensorflow/lite/micro/memory_planner/non_persistent_buffer_planner_shim.cc -o edge-impulse-sdk/tensorflow/lite/micro/memory_planner/non_persistent_buffer_planner_shim.o
    g++ -I. -g -Wno-strict-aliasing -Os -DNDEBUG -DEI_CLASSIFIER_ENABLE_DETECTION_POSTPROCESS_OP -DTF_LITE_DISABLE_X86_NEON=1 -std=c++11 -c edge-impulse-sdk/tensorflow/lite/core/api/common.cc -o edge-impulse-sdk/tensorflow/lite/core/api/common.o
    g++ -I. -g -Wno-strict-aliasing -Os -DNDEBUG -DEI_CLASSIFIER_ENABLE_DETECTION_POSTPROCESS_OP -DTF_LITE_DISABLE_X86_NEON=1 -std=c++11 -c edge-impulse-sdk/tensorflow/lite/core/api/error_reporter.cc -o edge-impulse-sdk/tensorflow/lite/core/api/error_reporter.o
    g++ -I. -g -Wno-strict-aliasing -Os -DNDEBUG -DEI_CLASSIFIER_ENABLE_DETECTION_POSTPROCESS_OP -DTF_LITE_DISABLE_X86_NEON=1 -std=c++11 -c edge-impulse-sdk/tensorflow/lite/core/api/flatbuffer_conversions.cc -o edge-impulse-sdk/tensorflow/lite/core/api/flatbuffer_conversions.o
    g++ -I. -g -Wno-strict-aliasing -Os -DNDEBUG -DEI_CLASSIFIER_ENABLE_DETECTION_POSTPROCESS_OP -DTF_LITE_DISABLE_X86_NEON=1 -std=c++11 -c edge-impulse-sdk/tensorflow/lite/core/api/op_resolver.cc -o edge-impulse-sdk/tensorflow/lite/core/api/op_resolver.o
    g++ -I. -g -Wno-strict-aliasing -Os -DNDEBUG -DEI_CLASSIFIER_ENABLE_DETECTION_POSTPROCESS_OP -DTF_LITE_DISABLE_X86_NEON=1 -std=c++11 -c edge-impulse-sdk/tensorflow/lite/core/api/tensor_utils.cc -o edge-impulse-sdk/tensorflow/lite/core/api/tensor_utils.o
    g++ -I. -g -Wno-strict-aliasing -Os -DNDEBUG -DEI_CLASSIFIER_ENABLE_DETECTION_POSTPROCESS_OP -DTF_LITE_DISABLE_X86_NEON=1 -std=c++11 -c tflite-model/tflite_learn_35_compiled.cpp -o tflite-model/tflite_learn_35_compiled.o
    In file included from ./edge-impulse-sdk/tensorflow/lite/micro/flatbuffer_utils.h:20:0,
    from ./edge-impulse-sdk/tensorflow/lite/micro/micro_allocator.h:24,
    from ./edge-impulse-sdk/tensorflow/lite/micro/micro_context.h:20,
    from ./edge-impulse-sdk/tensorflow/lite/micro/kernels/kernel_util.h:26,
    from ./edge-impulse-sdk/tensorflow/lite/micro/kernels/pooling.h:28,
    from ./edge-impulse-sdk/tensorflow/lite/micro/micro_mutable_op_resolver.h:33,
    from tflite-model/tflite_learn_35_compiled.cpp:37:
    ./edge-impulse-sdk/third_party/flatbuffers/include/flatbuffers/flexbuffers.h: In member function ‘double flexbuffers::Reference::AsDouble() const’:
    ./edge-impulse-sdk/third_party/flatbuffers/include/flatbuffers/flexbuffers.h:500:32: warning: unknown option after ‘#pragma GCC diagnostic’ kind [-Wpragmas]
    #pragma GCC diagnostic ignored “-Wnull-dereference”
    ^
    g++ -I. -g -Wno-strict-aliasing -Os -DNDEBUG -DEI_CLASSIFIER_ENABLE_DETECTION_POSTPROCESS_OP -DTF_LITE_DISABLE_X86_NEON=1 -std=c++11 -c edge-impulse-sdk/dsp/kissfft/kiss_fft.cpp -o edge-impulse-sdk/dsp/kissfft/kiss_fft.o
    g++ -I. -g -Wno-strict-aliasing -Os -DNDEBUG -DEI_CLASSIFIER_ENABLE_DETECTION_POSTPROCESS_OP -DTF_LITE_DISABLE_X86_NEON=1 -std=c++11 -c edge-impulse-sdk/dsp/kissfft/kiss_fftr.cpp -o edge-impulse-sdk/dsp/kissfft/kiss_fftr.o
    g++ -I. -g -Wno-strict-aliasing -Os -DNDEBUG -DEI_CLASSIFIER_ENABLE_DETECTION_POSTPROCESS_OP -DTF_LITE_DISABLE_X86_NEON=1 -std=c++11 -c edge-impulse-sdk/dsp/dct/fast-dct-fft.cpp -o edge-impulse-sdk/dsp/dct/fast-dct-fft.o
    g++ -I. -g -Wno-strict-aliasing -Os -DNDEBUG -DEI_CLASSIFIER_ENABLE_DETECTION_POSTPROCESS_OP -DTF_LITE_DISABLE_X86_NEON=1 -std=c++11 -c edge-impulse-sdk/dsp/memory.cpp -o edge-impulse-sdk/dsp/memory.o
    g++ -I. -g -Wno-strict-aliasing -Os -DNDEBUG -DEI_CLASSIFIER_ENABLE_DETECTION_POSTPROCESS_OP -DTF_LITE_DISABLE_X86_NEON=1 -std=c++11 -c edge-impulse-sdk/porting/posix/debug_log.cpp -o edge-impulse-sdk/porting/posix/debug_log.o
    g++ -I. -g -Wno-strict-aliasing -Os -DNDEBUG -DEI_CLASSIFIER_ENABLE_DETECTION_POSTPROCESS_OP -DTF_LITE_DISABLE_X86_NEON=1 -std=c++11 -c edge-impulse-sdk/porting/posix/ei_classifier_porting.cpp -o edge-impulse-sdk/porting/posix/ei_classifier_porting.o
    g++ -I. -g -Wno-strict-aliasing -Os -DNDEBUG -DEI_CLASSIFIER_ENABLE_DETECTION_POSTPROCESS_OP -DTF_LITE_DISABLE_X86_NEON=1 -std=c++11 -c source/main.cpp -o source/main.o
    In file included from ./edge-impulse-sdk/classifier/ei_model_types.h:42:0,
    from ./edge-impulse-sdk/classifier/ei_run_classifier.h:38,
    from source/main.cpp:12:
    ./edge-impulse-sdk/dsp/numpy.hpp:66:18: error: missing binary operator before token “(”
    #if __has_include(“model-parameters/model_metadata.h”)
    ^
    In file included from ./edge-impulse-sdk/third_party/flatbuffers/include/flatbuffers/fb_array.h:20:0,
    from ./edge-impulse-sdk/third_party/flatbuffers/include/flatbuffers/flatbuffers.h:22,
    from ./edge-impulse-sdk/tensorflow/lite/schema/schema_generated.h:4,
    from ./edge-impulse-sdk/tensorflow/lite/core/api/flatbuffer_conversions.h:28,
    from ./edge-impulse-sdk/tensorflow/lite/micro/micro_mutable_op_resolver.h:22,
    from ./edge-impulse-sdk/tensorflow/lite/micro/all_ops_resolver.h:19,
    from ./edge-impulse-sdk/classifier/inferencing_engines/tflite_helper.h:52,
    from ./edge-impulse-sdk/classifier/inferencing_engines/tflite_eon.h:45,
    from ./edge-impulse-sdk/classifier/ei_run_classifier.h:62,
    from source/main.cpp:12:
    ./edge-impulse-sdk/third_party/flatbuffers/include/flatbuffers/fb_base.h:232:22: error: missing binary operator before token “(”
    #if __has_include(<string_view>) && (__cplusplus >= 201606 || (defined(_HAS_CXX17) && _HAS_CXX17))
    ^
    ./edge-impulse-sdk/third_party/flatbuffers/include/flatbuffers/fb_base.h:239:24: error: missing binary operator before token “(”
    #elif __has_include(<experimental/string_view>) && (__cplusplus >= 201411)
    ^
    ./edge-impulse-sdk/third_party/flatbuffers/include/flatbuffers/fb_base.h:246:24: error: missing binary operator before token “(”
    #elif __has_include(“absl/strings/string_view.h”)
    ^
    In file included from ./edge-impulse-sdk/tensorflow/lite/micro/kernels/softmax.h:18:0,
    from ./edge-impulse-sdk/tensorflow/lite/micro/micro_mutable_op_resolver.h:35,
    from ./edge-impulse-sdk/tensorflow/lite/micro/all_ops_resolver.h:19,
    from ./edge-impulse-sdk/classifier/inferencing_engines/tflite_helper.h:52,
    from ./edge-impulse-sdk/classifier/inferencing_engines/tflite_eon.h:45,
    from ./edge-impulse-sdk/classifier/ei_run_classifier.h:62,
    from source/main.cpp:12:
    ./edge-impulse-sdk/classifier/ei_classifier_config.h:42:22: error: missing binary operator before token “(”
    #if __has_include(“source/benchmark.h”)
    ^
    In file included from ./edge-impulse-sdk/tensorflow/lite/micro/kernels/softmax.h:18:0,
    from ./edge-impulse-sdk/tensorflow/lite/micro/micro_mutable_op_resolver.h:35,
    from ./edge-impulse-sdk/tensorflow/lite/micro/all_ops_resolver.h:19,
    from ./edge-impulse-sdk/classifier/inferencing_engines/tflite_helper.h:52,
    from ./edge-impulse-sdk/classifier/inferencing_engines/tflite_eon.h:45,
    from ./edge-impulse-sdk/classifier/ei_run_classifier.h:62,
    from source/main.cpp:12:
    ./edge-impulse-sdk/classifier/ei_classifier_config.h:105:22: error: missing binary operator before token “(”
    #if __has_include(“tflite-model/trained_model_ops_define.h”)
    ^
    In file included from /usr/include/c++/4.8/vector:65:0,
    from ./edge-impulse-sdk/dsp/ei_vector.h:35,
    from ./edge-impulse-sdk/dsp/numpy_types.h:40,
    from ./edge-impulse-sdk/dsp/ei_dsp_handle.h:35,
    from ./edge-impulse-sdk/classifier/ei_model_types.h:41,
    from ./edge-impulse-sdk/classifier/ei_run_classifier.h:38,
    from source/main.cpp:12:
    /usr/include/c++/4.8/bits/stl_bvector.h: In instantiation of ‘struct std::_Bvector_base<ei::EiAlloc >’:
    /usr/include/c++/4.8/bits/stl_bvector.h:518:9: required from ‘class std::vector<bool, ei::EiAlloc >’
    ./edge-impulse-sdk/dsp/numpy.hpp:394:34: required from here
    /usr/include/c++/4.8/bits/stl_bvector.h:406:9: error: no class template named ‘rebind’ in ‘struct ei::EiAlloc’
    _Bit_alloc_type;
    ^
    /usr/include/c++/4.8/bits/stl_bvector.h: In instantiation of ‘class std::vector<bool, ei::EiAlloc >’:
    ./edge-impulse-sdk/dsp/numpy.hpp:394:34: required from here
    /usr/include/c++/4.8/bits/stl_bvector.h:547:18: error: no members matching ‘std::vector<bool, ei::EiAlloc >::_Base {aka std::_Bvector_base<ei::EiAlloc >}::_M_get_Bit_allocator’ in ‘std::vector<bool, ei::EiAlloc >::_Base {aka struct std::_Bvector_base<ei::EiAlloc >}’
    using _Base::_M_get_Bit_allocator;
    ^
    In file included from ./edge-impulse-sdk/tensorflow/lite/micro/flatbuffer_utils.h:20:0,
    from ./edge-impulse-sdk/tensorflow/lite/micro/micro_allocator.h:24,
    from ./edge-impulse-sdk/tensorflow/lite/micro/micro_context.h:20,
    from ./edge-impulse-sdk/tensorflow/lite/micro/kernels/kernel_util.h:26,
    from ./edge-impulse-sdk/tensorflow/lite/micro/kernels/pooling.h:28,
    from ./edge-impulse-sdk/tensorflow/lite/micro/micro_mutable_op_resolver.h:33,
    from ./edge-impulse-sdk/tensorflow/lite/micro/all_ops_resolver.h:19,
    from ./edge-impulse-sdk/classifier/inferencing_engines/tflite_helper.h:52,
    from ./edge-impulse-sdk/classifier/inferencing_engines/tflite_eon.h:45,
    from ./edge-impulse-sdk/classifier/ei_run_classifier.h:62,
    from source/main.cpp:12:
    ./edge-impulse-sdk/third_party/flatbuffers/include/flatbuffers/flexbuffers.h: In member function ‘double flexbuffers::Reference::AsDouble() const’:
    ./edge-impulse-sdk/third_party/flatbuffers/include/flatbuffers/flexbuffers.h:500:32: warning: unknown option after ‘#pragma GCC diagnostic’ kind [-Wpragmas]
    #pragma GCC diagnostic ignored “-Wnull-dereference”
    ^
    In file included from /usr/include/c++/4.8/vector:65:0,
    from ./edge-impulse-sdk/dsp/ei_vector.h:35,
    from ./edge-impulse-sdk/dsp/numpy_types.h:40,
    from ./edge-impulse-sdk/dsp/ei_dsp_handle.h:35,
    from ./edge-impulse-sdk/classifier/ei_model_types.h:41,
    from ./edge-impulse-sdk/classifier/ei_run_classifier.h:38,
    from source/main.cpp:12:
    /usr/include/c++/4.8/bits/stl_bvector.h: In instantiation of ‘std::_Bvector_base<_Alloc>::_Bvector_base(const allocator_type&) [with _Alloc = ei::EiAlloc; std::_Bvector_base<_Alloc>::allocator_type = ei::EiAlloc]’:
    /usr/include/c++/4.8/bits/stl_bvector.h:565:16: required from ‘std::vector<bool, _Alloc>::vector(std::vector<bool, _Alloc>::size_type, const bool&, const allocator_type&) [with _Alloc = ei::EiAlloc; std::vector<bool, _Alloc>::size_type = long unsigned int; std::vector<bool, _Alloc>::allocator_type = ei::EiAlloc]’
    ./edge-impulse-sdk/dsp/numpy.hpp:394:46: required from here
    /usr/include/c++/4.8/bits/stl_bvector.h:450:20: error: no matching function for call to ‘std::_Bvector_base<ei::EiAlloc >::_Bvector_impl::_Bvector_impl(const allocator_type&)’
    : _M_impl(__a) { }
    ^
    /usr/include/c++/4.8/bits/stl_bvector.h:450:20: note: candidates are:
    /usr/include/c++/4.8/bits/stl_bvector.h:415:2: note: std::_Bvector_base<_Alloc>::_Bvector_impl::_Bvector_impl() [with _Alloc = ei::EiAlloc]
    _Bvector_impl()
    ^
    /usr/include/c++/4.8/bits/stl_bvector.h:415:2: note: candidate expects 0 arguments, 1 provided
    /usr/include/c++/4.8/bits/stl_bvector.h:408:14: note: constexpr std::_Bvector_base<ei::EiAlloc >::_Bvector_impl::_Bvector_impl(const std::_Bvector_base<ei::EiAlloc >::_Bvector_impl&)
    struct _Bvector_impl
    ^
    /usr/include/c++/4.8/bits/stl_bvector.h:408:14: note: no known conversion for argument 1 from ‘const allocator_type {aka const ei::EiAlloc}’ to ‘const std::_Bvector_base<ei::EiAlloc >::_Bvector_impl&’
    /usr/include/c++/4.8/bits/stl_bvector.h:408:14: note: constexpr std::_Bvector_base<ei::EiAlloc >::_Bvector_impl::_Bvector_impl(std::_Bvector_base<ei::EiAlloc >::_Bvector_impl&&)
    /usr/include/c++/4.8/bits/stl_bvector.h:408:14: note: no known conversion for argument 1 from ‘const allocator_type {aka const ei::EiAlloc}’ to ‘std::_Bvector_base<ei::EiAlloc >::_Bvector_impl&&’
    /usr/include/c++/4.8/bits/stl_bvector.h: In instantiation of ‘void std::_Bvector_base<_Alloc>::_M_deallocate() [with _Alloc = ei::EiAlloc]’:
    /usr/include/c++/4.8/bits/stl_bvector.h:466:9: required from ‘std::_Bvector_base<_Alloc>::~_Bvector_base() [with _Alloc = ei::EiAlloc]’
    /usr/include/c++/4.8/bits/stl_bvector.h:565:16: required from ‘std::vector<bool, _Alloc>::vector(std::vector<bool, _Alloc>::size_type, const bool&, const allocator_type&) [with _Alloc = ei::EiAlloc; std::vector<bool, _Alloc>::size_type = long unsigned int; std::vector<bool, _Alloc>::allocator_type = ei::EiAlloc]’
    ./edge-impulse-sdk/dsp/numpy.hpp:394:46: required from here
    /usr/include/c++/4.8/bits/stl_bvector.h:479:4: error: ‘struct std::_Bvector_base<ei::EiAlloc >::_Bvector_impl’ has no member named ‘deallocate’
    _M_impl.deallocate(_M_impl._M_start._M_p,
    ^
    /usr/include/c++/4.8/bits/stl_bvector.h: In instantiation of ‘std::_Bit_type* std::_Bvector_base<_Alloc>::_M_allocate(std::size_t) [with _Alloc = ei::EiAlloc; std::_Bit_type = long unsigned int; std::size_t = long unsigned int]’:
    /usr/include/c++/4.8/bits/stl_bvector.h:959:45: required from ‘void std::vector<bool, _Alloc>::_M_initialize(std::vector<bool, _Alloc>::size_type) [with _Alloc = ei::EiAlloc; std::vector<bool, _Alloc>::size_type = long unsigned int]’
    /usr/include/c++/4.8/bits/stl_bvector.h:567:24: required from ‘std::vector<bool, _Alloc>::vector(std::vector<bool, _Alloc>::size_type, const bool&, const allocator_type&) [with _Alloc = ei::EiAlloc; std::vector<bool, _Alloc>::size_type = long unsigned int; std::vector<bool, _Alloc>::allocator_type = ei::EiAlloc]’
    ./edge-impulse-sdk/dsp/numpy.hpp:394:46: required from here
    /usr/include/c++/4.8/bits/stl_bvector.h:473:46: error: ‘struct std::_Bvector_base<ei::EiAlloc >::_Bvector_impl’ has no member named ‘allocate’
    { return _M_impl.allocate(_S_nword(__n)); }
    ^
    make: *** [Makefile:103: source/main.o] Error 1

Additional Information: