【TF Lite】First Example of Tensorflow Lite

依赖安装阶段:

  1. Install the latest version of Bazel as per the instructions on the Bazel website.

  2. The Android NDK is required to build the native (C/C++) TensorFlow code. The current recommended version is 14b, which may be found here.

  3. The Android SDK and build tools may be obtained here, or alternatively as part of Android Studio. Build tools API >= 23 is required to build the TF Android demo (though it will run on API >= 21 devices).

编译阶段:

  1. ./configure
    :tensorflow android 编译过程中,要首先在 tensorflow 根目录下配置 configure 文件,除了android ndk的配置选择Yes,其他配置项选择默认路径和No即可。
  2. bazel build --cxxopt=’–std=c++11’ -c opt //tensorflow/examples/android:tensorflow_demo
    :增加 –cxxopt=’–std=c++11’ 参数,是因为mac 默认c++版本为11,因此增加
    这里编译报错:
ERROR:
/private/var/tmp/_bazel_royalli/eaf3ba72603dc130004478a5b17571b5/external/com_google_absl/absl/base/BUILD.bazel:29:1: C++ compilation of rule '@com_google_absl//absl/base:spinlock_wait' failed (Exit 1)
In file included from external/com_google_absl/absl/base/internal/spinlock_wait.cc:27:
In file included from external/com_google_absl/absl/base/internal/spinlock_linux.inc:17:
external/androidndk/ndk/platforms/android-14/arch-arm/usr/include/linux/futex.h:28:21: error: field has incomplete type 'struct robust_list'
 struct robust_list __user *next;
                    ^
external/androidndk/ndk/platforms/android-14/arch-arm/usr/include/linux/futex.h:27:8: note: definition of 'robust_list' is not complete until the closing '}'
struct robust_list {
       ^
external/androidndk/ndk/platforms/android-14/arch-arm/usr/include/linux/futex.h:28:27: error: expected ';' at end of declaration list
 struct robust_list __user *next;
                          ^
external/androidndk/ndk/platforms/android-14/arch-arm/usr/include/linux/futex.h:37:27: error: expected ';' at end of declaration list
 struct robust_list __user *list_op_pending;

解决方法参考:https://blog.csdn.net/weixin_41480546/article/details/87533166
找到futex.h,增加宏定义:

vim ./platforms/android-14/arch-arm/usr/include/linux/futex.h

增加宏

#ifndef __user
#define __user
#endif

参考文章:
https://blog.csdn.net/weixin_39653948/article/details/82660026
https://blog.csdn.net/weixin_41480546/article/details/87533166

猜你喜欢

转载自blog.csdn.net/sinat_21720047/article/details/88736467