【发布时间】:2018-01-25 16:57:29
【问题描述】:
我已经从 ghit 下载了 tensorflow, 我使用我的 android sdk 和 android ndk 配置 WORKSPACE 文件。
我从命令行运行 ./configure
我用 buzel 构建
bazel build -c opt //tensorflow/contrib/android:libtensorflow_inference.so --crosstool_top=//external:android/crosstool --cpu=armeabi-v7a --host_crosstool_top=@bazel_tools//tools/cpp:toolchain --config=android --fat_apk_cpu=armeabi-v7a --verbose_failures
构建工作正常。
当我进入 Android Studio 时,我将我的 libtensorflow_inference.so 包含在 jnilibs 文件夹中,在 CMakefile.txt 中我包含了所有 .h 文件的目录和tenorflow 依赖项。
CMakefile.txt
#include header file
#TENSORFLOW
include_directories(${pathTensorflow})
#TENSORFLOW dependeces
include_directories(${pathToWorkspace}/downloads/nsync/public)
include_directories(${pathToWorkspace}/downloads/protobuf/src)
include_directories(${pathToWorkspace}/downloads/eigen)
#include tensorflow shared library
add_library( lib_TF SHARED IMPORTED )
set_target_properties(lib_TF PROPERTIES IMPORTED_LOCATION ${pathToProject}/src/main/jnilibs/${ANDROID_ABI}/libtensorflow_inference.so)
target_link_libraries( # Specifies the target library.
myLibcpp
lib_TF
...
)
在我的文件 cpp 中,我已插入此代码
tensorflow::GraphDef graph_def;
但是当我运行 make 文件时,我收到了这个错误
Error:error: linker command failed with exit code 1 (use -v to see invocation)
Error:(100) undefined reference to 'tensorflow::GraphDef::GraphDef()'
【问题讨论】:
标签: android c++ android-studio tensorflow native