Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
C++ Compile Problem ( Flatbuffers) and Tensor flow Micro
#1
Hi! I have been trying to compile Tensor flow Lite Micro Arduino Port (https://github.com/tensorflow/tflite-mic...o-examples)  on STM32 with EmBitz 2.5.

Adding the folders/files  to an empty C++ project for an STM32F4 target as neeed. (TensorFlow and ThirdyParty folders and TensorFlowLite.h) .

The problem comes with the Flatbuffers lib (At  ThirdyParty  folder) that it's a bunch of .h file with C++ content.

It seems that the ide cannot assing C++ libs for this specifc library. This Tensor flow port is intended to run on CM4 targets on arduino so it should works with Embits???

Can some one help? The hw/firmware part of the for the project it's almost done I only need to build this library with Embitz and I don't want to chance for STMcube  Confused

Any one can help please?

Errors attached below:

Code:
.\cmsis\..\third_party\flatbuffers\include\flatbuffers\buffer.h|27|error: 'uoffset_t' does not name a type; did you mean 'offsetof'?|
.\cmsis\..\third_party\flatbuffers\include\flatbuffers\buffer.h|29|error: expected ')' before '_o'|
.\cmsis\..\third_party\flatbuffers\include\flatbuffers\buffer.h|28|error: class 'flatbuffers::Offset<T>' does not have any field named 'o'|
.\cmsis\..\third_party\flatbuffers\include\flatbuffers\buffer.h|30|error: 'o' was not declared in this scope|
.\cmsis\..\third_party\flatbuffers\include\flatbuffers\buffer.h|31|error: 'o' was not declared in this scope|
src\base.h|31|error: 'FLATBUFFERS_LITTLEENDIAN' was not declared in this scope|
src\base.h|31|note: the macro 'FLATBUFFERS_LITTLEENDIAN' had not yet been defined|
src\base.h|138|note: it was later defined here|
.\cmsis\..\third_party\flatbuffers\include\flatbuffers\buffer.h|42|error: 'FLATBUFFERS_CONSTEXPR' does not name a type|
.\cmsis\..\third_party\flatbuffers\include\flatbuffers\buffer.h|42|note: the macro 'FLATBUFFERS_CONSTEXPR' had not yet been defined|
src\base.h|178|note: it was later defined here|
.\cmsis\..\third_party\flatbuffers\include\flatbuffers\buffer.h|58|error: 'uoffset_t' has not been declared|
.\cmsis\..\third_party\flatbuffers\include\flatbuffers\buffer.h|59|error: 'uoffset_t' has not been declared|
.\cmsis\..\third_party\flatbuffers\include\flatbuffers\buffer.h|60|error: 'min' is not a member of 'std'|
.\cmsis\..\third_party\flatbuffers\include\flatbuffers\buffer.h|60|error: 'memcmp' was not declared in this scope|
.\cmsis\..\third_party\flatbuffers\include\flatbuffers\buffer.h|22|note: 'memcmp' is defined in header '<cstring>'; did you forget to '#include <cstring>'?|
.\cmsis\..\third_party\flatbuffers\include\flatbuffers\buffer.h|76|error: 'uoffset_t' has not been declared|
.\cmsis\..\third_party\flatbuffers\include\flatbuffers\buffer.h|83|error: 'uoffset_t' was not declared in this scope; did you mean 'offsetof'?|
.\cmsis\..\third_party\flatbuffers\include\flatbuffers\buffer.h|84|error: 'uoffset_t' has not been declared|
.\cmsis\..\third_party\flatbuffers\include\flatbuffers\buffer.h|85|error: 'uoffset_t' was not declared in this scope; did you mean 'offsetof'?|
.\cmsis\..\third_party\flatbuffers\include\flatbuffers\buffer.h|86|error: 'ReadScalar' was not declared in this scope|
.\cmsis\..\third_party\flatbuffers\include\flatbuffers\buffer.h|93|error: 'uoffset_t' has not been declared|
.\cmsis\..\third_party\flatbuffers\include\flatbuffers\buffer.h|108|error: 'uoffset_t' was not declared in this scope; did you mean 'offsetof'?|
.\cmsis\..\third_party\flatbuffers\include\flatbuffers\buffer.h|115|error: 'kFileIdentifierLength' is not a member of 'flatbuffers'|
.\cmsis\..\third_party\flatbuffers\include\flatbuffers\buffer.h|114|error: 'strncmp' was not declared in this scope|
.\cmsis\..\third_party\flatbuffers\include\flatbuffers\buffer.h|114|note: 'strncmp' is defined in header '<cstring>'; did you forget to '#include <cstring>'?|
.\cmsis\..\third_party\flatbuffers\include\flatbuffers\buffer.h|124|error: 'uoffset_t' does not name a type; did you mean 'offsetof'?|
.\cmsis\..\third_party\flatbuffers\include\flatbuffers\buffer.h|124|error: expected '>' before '*' token|
.\cmsis\..\third_party\flatbuffers\include\flatbuffers\buffer.h|124|error: expected '(' before '*' token|
.\cmsis\..\third_party\flatbuffers\include\flatbuffers\buffer.h|124|error: expected primary-expression before '>' token|
.\cmsis\..\third_party\flatbuffers\include\flatbuffers\buffer.h|124|error: there are no arguments to 'EndianScalar' that depend on a template parameter, so a declaration of 'EndianScalar' must be available [-fpermissive]|
.\cmsis\..\third_party\flatbuffers\include\flatbuffers\buffer.h|124|note: (if you use '-fpermissive', G++ will accept your code, but allowing the use of an undeclared name is deprecated)|
.\cmsis\..\third_party\flatbuffers\include\flatbuffers\buffer.h|124|error: expected ')' before ';' token|
.\cmsis\..\third_party\flatbuffers\include\flatbuffers\buffer.h|129|error: 'uoffset_t' was not declared in this scope; did you mean 'offsetof'?|
.\cmsis\..\third_party\flatbuffers\include\flatbuffers\buffer.h|137|error: 'uoffset_t' was not declared in this scope; did you mean 'offsetof'?|
.\cmsis\..\third_party\flatbuffers\include\flatbuffers\stl_emulation.h|148|error: 'FLATBUFFERS_CONSTEXPR_CPP11' does not name a type|
.\cmsis\..\third_party\flatbuffers\include\flatbuffers\stl_emulation.h|148|note: the macro 'FLATBUFFERS_CONSTEXPR_CPP11' had not yet been defined|
src\base.h|179|note: it was later defined here|
.\cmsis\..\third_party\flatbuffers\include\flatbuffers\stl_emulation.h|169|  required from here|
.\cmsis\..\third_party\flatbuffers\include\flatbuffers\stl_emulation.h|167|error: no matching function for call to 'flatbuffers::nullopt_t::nullopt_t(int)'|
.\cmsis\..\third_party\flatbuffers\include\flatbuffers\stl_emulation.h|147|note: candidate: 'constexpr flatbuffers::nullopt_t::nullopt_t()'|
.\cmsis\..\third_party\flatbuffers\include\flatbuffers\stl_emulation.h|147|note:   candidate expects 0 arguments, 1 provided|
.\cmsis\..\third_party\flatbuffers\include\flatbuffers\stl_emulation.h|147|note: candidate: 'constexpr flatbuffers::nullopt_t::nullopt_t(const flatbuffers::nullopt_t&)'|
.\cmsis\..\third_party\flatbuffers\include\flatbuffers\stl_emulation.h|147|note:   no known conversion for argument 1 from 'int' to 'const flatbuffers::nullopt_t&'|
.\cmsis\..\third_party\flatbuffers\include\flatbuffers\stl_emulation.h|147|note: candidate: 'constexpr flatbuffers::nullopt_t::nullopt_t(flatbuffers::nullopt_t&&)'|
.\cmsis\..\third_party\flatbuffers\include\flatbuffers\stl_emulation.h|147|note:   no known conversion for argument 1 from 'int' to 'flatbuffers::nullopt_t&&'|
.\cmsis\..\third_party\flatbuffers\include\flatbuffers\stl_emulation.h|178|error: expected primary-expression before 'static_assert'|
.\cmsis\..\third_party\flatbuffers\include\flatbuffers\stl_emulation.h|178|error: expected '}' before 'static_assert'|
.\cmsis\..\third_party\flatbuffers\include\flatbuffers\stl_emulation.h|174|note: to match this '{'|
.\cmsis\..\third_party\flatbuffers\include\flatbuffers\stl_emulation.h|174|error: expected ';' before 'static_assert'|
.\cmsis\..\third_party\flatbuffers\include\flatbuffers\stl_emulation.h|180|error: expected unqualified-id before 'public'|
.\cmsis\..\third_party\flatbuffers\include\flatbuffers\stl_emulation.h|183|error: 'FLATBUFFERS_CONSTEXPR_CPP11' does not name a type|
.\cmsis\..\third_party\flatbuffers\include\flatbuffers\stl_emulation.h|183|note: the macro 'FLATBUFFERS_CONSTEXPR_CPP11' had not yet been defined|
src\base.h|179|note: it was later defined here|
.\cmsis\..\third_party\flatbuffers\include\flatbuffers\stl_emulation.h|186|error: 'FLATBUFFERS_CONSTEXPR_CPP11' does not name a type|
.\cmsis\..\third_party\flatbuffers\include\flatbuffers\stl_emulation.h|186|note: the macro 'FLATBUFFERS_CONSTEXPR_CPP11' had not yet been defined|
src\base.h|179|note: it was later defined here|
.\cmsis\..\third_party\flatbuffers\include\flatbuffers\stl_emulation.h|189|error: 'FLATBUFFERS_CONSTEXPR_CPP11' does not name a type|
.\cmsis\..\third_party\flatbuffers\include\flatbuffers\stl_emulation.h|189|note: the macro 'FLATBUFFERS_CONSTEXPR_CPP11' had not yet been defined|
src\base.h|179|note: it was later defined here|
.\cmsis\..\third_party\flatbuffers\include\flatbuffers\stl_emulation.h|192|error: 'FLATBUFFERS_CONSTEXPR_CPP11' does not name a type|
.\cmsis\..\third_party\flatbuffers\include\flatbuffers\stl_emulation.h|192|note: the macro 'FLATBUFFERS_CONSTEXPR_CPP11' had not yet been defined|
src\base.h|179|note: it was later defined here|
.\cmsis\..\third_party\flatbuffers\include\flatbuffers\stl_emulation.h|195|error: 'FLATBUFFERS_CONSTEXPR_CPP14' does not name a type|
.\cmsis\..\third_party\flatbuffers\include\flatbuffers\stl_emulation.h|195|note: the macro 'FLATBUFFERS_CONSTEXPR_CPP14' had not yet been defined|
src\base.h|188|note: it was later defined here|
.\cmsis\..\third_party\flatbuffers\include\flatbuffers\stl_emulation.h|201|error: 'FLATBUFFERS_CONSTEXPR_CPP14' does not name a type|
.\cmsis\..\third_party\flatbuffers\include\flatbuffers\stl_emulation.h|201|note: the macro 'FLATBUFFERS_CONSTEXPR_CPP14' had not yet been defined|
src\base.h|188|note: it was later defined here|
.\cmsis\..\third_party\flatbuffers\include\flatbuffers\stl_emulation.h|207|error: 'FLATBUFFERS_CONSTEXPR_CPP14' does not name a type|
.\cmsis\..\third_party\flatbuffers\include\flatbuffers\stl_emulation.h|207|note: the macro 'FLATBUFFERS_CONSTEXPR_CPP14' had not yet been defined|
src\base.h|188|note: it was later defined here|
.\cmsis\..\third_party\flatbuffers\include\flatbuffers\stl_emulation.h|213|error: expected initializer before 'FLATBUFFERS_NOEXCEPT'|
.\cmsis\..\third_party\flatbuffers\include\flatbuffers\stl_emulation.h|217|error: expected initializer before 'FLATBUFFERS_NOEXCEPT'|
.\cmsis\..\third_party\flatbuffers\include\flatbuffers\stl_emulation.h|222|error: 'FLATBUFFERS_CONSTEXPR_CPP11' does not name a type|
.\cmsis\..\third_party\flatbuffers\include\flatbuffers\stl_emulation.h|222|note: the macro 'FLATBUFFERS_CONSTEXPR_CPP11' had not yet been defined|
src\base.h|179|note: it was later defined here|
.\cmsis\..\third_party\flatbuffers\include\flatbuffers\stl_emulation.h|226|error: 'FLATBUFFERS_CONSTEXPR_CPP11' does not name a type|
.\cmsis\..\third_party\flatbuffers\include\flatbuffers\stl_emulation.h|226|note: the macro 'FLATBUFFERS_CONSTEXPR_CPP11' had not yet been defined|
src\base.h|179|note: it was later defined here|
.\cmsis\..\third_party\flatbuffers\include\flatbuffers\stl_emulation.h|230|error: 'FLATBUFFERS_CONSTEXPR_CPP11' does not name a type|
.\cmsis\..\third_party\flatbuffers\include\flatbuffers\stl_emulation.h|230|note: the macro 'FLATBUFFERS_CONSTEXPR_CPP11' had not yet been defined|
src\base.h|179|note: it was later defined here|
.\cmsis\..\third_party\flatbuffers\include\flatbuffers\stl_emulation.h|234|error: 'T' does not name a type|
.\cmsis\..\third_party\flatbuffers\include\flatbuffers\stl_emulation.h|239|error: 'T' does not name a type|
.\cmsis\..\third_party\flatbuffers\include\flatbuffers\stl_emulation.h|243|error: expected unqualified-id before 'private'|
||More errors follow but not being shown.|
||Edit the max errors limit in compiler options...|
||=== Finished: 50 errors, 0 warnings (0 minutes, 6 seconds) ===|


flatbuffers (buffer.h) part:

Code:
#include <base.h>
#include <cstdint>
namespace flatbuffers {

// Wrapper for uoffset_t to allow safe template specialization.
// Value is allowed to be 0 to indicate a null object (see e.g. AddOffset).
template<typename T> struct Offset {
  uoffset_t o;
  Offset() : o(0) {}
  Offset(uoffset_t _o) : o(_o) {}
  Offset<void> Union() const { return Offset<void>(o); }
  bool IsNull() const { return !o; }
};

inline void EndianCheck() {
  int endiantest = 1;
  // If this fails, see FLATBUFFERS_LITTLEENDIAN above.
  FLATBUFFERS_ASSERT(*reinterpret_cast<char *>(&endiantest) ==
                     FLATBUFFERS_LITTLEENDIAN);
  (void)endiantest;
}

template<typename T> FLATBUFFERS_CONSTEXPR size_t AlignOf() {
  // clang-format off
  #ifdef _MSC_VER
    return __alignof(T);
  #else
    #ifndef alignof
      return __alignof__(T);
    #else
      return alignof(T);
    #endif
  #endif
  // clang-format on
}

// Lexicographically compare two strings (possibly containing nulls), and
// return true if the first is less than the second.
static inline bool StringLessThan(const char *a_data, uoffset_t a_size,
                                  const char *b_data, uoffset_t b_size) {
  const auto cmp = memcmp(a_data, b_data, (std::min)(a_size, b_size));
  return cmp == 0 ? a_size < b_size : cmp < 0;
}

// When we read serialized data from memory, in the case of most scalars,
// we want to just read T, but in the case of Offset, we want to actually
// perform the indirection and return a pointer.
// The template specialization below does just that.
// It is wrapped in a struct since function templates can't overload on the
// return type like this.
// The typedef is for the convenience of callers of this function
// (avoiding the need for a trailing return decltype)
template<typename T> struct IndirectHelper {
  typedef T return_type;
  typedef T mutable_return_type;
  static const size_t element_stride = sizeof(T);
  static return_type Read(const uint8_t *p, uoffset_t i) {
    return EndianScalar((reinterpret_cast<const T *>(p))[i]);
  }
};
template<typename T> struct IndirectHelper<Offset<T>> {
  typedef const T *return_type;
  typedef T *mutable_return_type;
  static const size_t element_stride = sizeof(uoffset_t);
  static return_type Read(const uint8_t *p, uoffset_t i) {
    p += i * sizeof(uoffset_t);
    return reinterpret_cast<return_type>(p + ReadScalar<uoffset_t>(p));
  }
};
template<typename T> struct IndirectHelper<const T *> {
  typedef const T *return_type;
  typedef T *mutable_return_type;
  static const size_t element_stride = sizeof(T);
  static return_type Read(const uint8_t *p, uoffset_t i) {
    return reinterpret_cast<const T *>(p + i * sizeof(T));
  }
};

/// @brief Get a pointer to the the file_identifier section of the buffer.
/// @return Returns a const char pointer to the start of the file_identifier
/// characters in the buffer.  The returned char * has length
/// 'flatbuffers::FlatBufferBuilder::kFileIdentifierLength'.
/// This function is UNDEFINED for FlatBuffers whose schema does not include
/// a file_identifier (likely points at padding or the start of a the root
/// vtable).
inline const char *GetBufferIdentifier(const void *buf,
                                       bool size_prefixed = false) {
  return reinterpret_cast<const char *>(buf) +
         ((size_prefixed) ? 2 * sizeof(uoffset_t) : sizeof(uoffset_t));
}

// Helper to see if the identifier in a buffer has the expected value.
inline bool BufferHasIdentifier(const void *buf, const char *identifier,
                                bool size_prefixed = false) {
  return strncmp(GetBufferIdentifier(buf, size_prefixed), identifier,
                 flatbuffers::kFileIdentifierLength) == 0;
}

/// @cond FLATBUFFERS_INTERNAL
// Helpers to get a typed pointer to the root object contained in the buffer.
template<typename T> T *GetMutableRoot(void *buf) {
  EndianCheck();
  return reinterpret_cast<T *>(
      reinterpret_cast<uint8_t *>(buf) +
      EndianScalar(*reinterpret_cast<uoffset_t *>(buf)));
}

template<typename T> T *GetMutableSizePrefixedRoot(void *buf) {
  return GetMutableRoot<T>(reinterpret_cast<uint8_t *>(buf) +
                           sizeof(uoffset_t));
}

template<typename T> const T *GetRoot(const void *buf) {
  return GetMutableRoot<T>(const_cast<void *>(buf));
}

template<typename T> const T *GetSizePrefixedRoot(const void *buf) {
  return GetRoot<T>(reinterpret_cast<const uint8_t *>(buf) + sizeof(uoffset_t));
}

}  // namespace flatbuffers

#endif  // FLATBUFFERS_BUFFER_H_
Reply
#2
Those libraries, with which compiler and version are they build?
Reply
#3
(31-03-2023, 03:23 PM)embitz Wrote: Those libraries, with which compiler and version are they build?

Thanks for the fast reply!

Do you mean at Arduino or with Embitz?

Version of the library is the same version as in the repo: https://github.com/tensorflow/tflite-mic...o-examples

I think the version of the flatbuffers is 2.0.6

Compiler: The toolchain  of the Embitz 2.50

I'am following this guide:

https://github.com/tensorflow/tflite-mic...support.md

It's stated that:

Note that for IDEs, it might be sufficient to simply include the folder created by the TFLM project generation script into the overall IDE tree.

(31-03-2023, 03:23 PM)embitz Wrote: Those libraries, with which compiler and version are they build?
Arduino compiler version: ./arm-none-eabi-gcc -v

gcc version 7.2.1 20170904 (release) [ARM/embedded-7-branch revision 255204] (GNU Tools for Arm Embedded Processors 7-2017-q4-major)
Reply
#4
Can I download your project somewhere?
Reply
#5
Hi! I think I will try to make a static C Library ".a " as stated here: https://github.com/tensorflow/tflite-mic.../README.md using the makefile  way  and include in the project. I think that i will change the cross compile toolchanin on Embitz or compile with the same version  (but for linux host) and see if i can integrate with Embitz maybe it's a better way... I will get in touch later on this.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)