【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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值