{"action":"created","issue":{"url":"https://api.github.com/repos/tensorflow/tensorflow/issues/19642","repository_url":"https://api.github.com/repos/tensorflow/tensorflow","labels_url":"https://api.github.com/repos/tensorflow/tensorflow/issues/19642/labels{/name}","comments_url":"https://api.github.com/repos/tensorflow/tensorflow/issues/19642/comments","events_url":"https://api.github.com/repos/tensorflow/tensorflow/issues/19642/events","html_url":"https://github.com/tensorflow/tensorflow/issues/19642","id":327655172,"node_id":"MDU6SXNzdWUzMjc2NTUxNzI=","number":19642,"title":"Linking issues with tensorflow-lite.a with android-studio and CMake.","user":{"login":"uelordi01","id":12067904,"node_id":"MDQ6VXNlcjEyMDY3OTA0","avatar_url":"https://avatars2.githubusercontent.com/u/12067904?v=4","gravatar_id":"","url":"https://api.github.com/users/uelordi01","html_url":"https://github.com/uelordi01","followers_url":"https://api.github.com/users/uelordi01/followers","following_url":"https://api.github.com/users/uelordi01/following{/other_user}","gists_url":"https://api.github.com/users/uelordi01/gists{/gist_id}","starred_url":"https://api.github.com/users/uelordi01/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/uelordi01/subscriptions","organizations_url":"https://api.github.com/users/uelordi01/orgs","repos_url":"https://api.github.com/users/uelordi01/repos","events_url":"https://api.github.com/users/uelordi01/events{/privacy}","received_events_url":"https://api.github.com/users/uelordi01/received_events","type":"User","site_admin":false},"labels":[{"id":750616506,"node_id":"MDU6TGFiZWw3NTA2MTY1MDY=","url":"https://api.github.com/repos/tensorflow/tensorflow/labels/comp:lite","name":"comp:lite","color":"0052cc","default":false},{"id":386191887,"node_id":"MDU6TGFiZWwzODYxOTE4ODc=","url":"https://api.github.com/repos/tensorflow/tensorflow/labels/stat:awaiting%20response","name":"stat:awaiting response","color":"f4b400","default":false}],"state":"closed","locked":false,"assignee":{"login":"shashishekhar","id":1162712,"node_id":"MDQ6VXNlcjExNjI3MTI=","avatar_url":"https://avatars1.githubusercontent.com/u/1162712?v=4","gravatar_id":"","url":"https://api.github.com/users/shashishekhar","html_url":"https://github.com/shashishekhar","followers_url":"https://api.github.com/users/shashishekhar/followers","following_url":"https://api.github.com/users/shashishekhar/following{/other_user}","gists_url":"https://api.github.com/users/shashishekhar/gists{/gist_id}","starred_url":"https://api.github.com/users/shashishekhar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/shashishekhar/subscriptions","organizations_url":"https://api.github.com/users/shashishekhar/orgs","repos_url":"https://api.github.com/users/shashishekhar/repos","events_url":"https://api.github.com/users/shashishekhar/events{/privacy}","received_events_url":"https://api.github.com/users/shashishekhar/received_events","type":"User","site_admin":false},"assignees":[{"login":"shashishekhar","id":1162712,"node_id":"MDQ6VXNlcjExNjI3MTI=","avatar_url":"https://avatars1.githubusercontent.com/u/1162712?v=4","gravatar_id":"","url":"https://api.github.com/users/shashishekhar","html_url":"https://github.com/shashishekhar","followers_url":"https://api.github.com/users/shashishekhar/followers","following_url":"https://api.github.com/users/shashishekhar/following{/other_user}","gists_url":"https://api.github.com/users/shashishekhar/gists{/gist_id}","starred_url":"https://api.github.com/users/shashishekhar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/shashishekhar/subscriptions","organizations_url":"https://api.github.com/users/shashishekhar/orgs","repos_url":"https://api.github.com/users/shashishekhar/repos","events_url":"https://api.github.com/users/shashishekhar/events{/privacy}","received_events_url":"https://api.github.com/users/shashishekhar/received_events","type":"User","site_admin":false}],"milestone":null,"comments":15,"created_at":"2018-05-30T09:48:11Z","updated_at":"2018-11-09T09:21:40Z","closed_at":"2018-07-19T01:39:05Z","author_association":"NONE","body":"### System information\r\n- **Have I written custom code:**\r\n- **OS Platform and Distribution ( )**:\r\nLinux Ubuntu 16.04 / Android\r\n- **TensorFlow installed from:**\r\n source\r\n\r\n- **Python version**: \r\n2.7\r\n- **Bazel version (if compiling from source)**:\r\n0.13\r\n- **GCC/Compiler version (if compiling from source)**:\r\nNDK16b \r\n\r\n### Describe the problem\r\nI am having problems linking libtensorflow-lite.a with CMake and Android Studio. \r\nIt seems that the tf-lite library is not compatible with my architecture, but I do not know why this is happening. \r\nI have succesfully compiled the libtensorflow-lite.a library, following these steps: \r\n\r\n```\r\nexport NDK_ROOT=<your_ndk>\r\ntensorflow/contrib/lite/download_dependencies.sh\r\nmake -f tensorflow/contrib/lite/Makefile TARGET=ANDROID ANDROID_ARCH=armeabi-v7a\r\n```\r\nThe problem comes when I try to link the library with CMake. it seems that even I compiled the armeabi-v7a the linker, I have these errors: \r\n\r\n>  incompatible target\r\n\r\n>  the vtable symbol may be undefined because the class is missing its key function\r\n\r\n### Source code / logs\r\nThis my error log: \r\n```\r\nBuild command failed.\r\nError while executing process /home/VICOMTECH/uelordi/Android/Sdk/cmake/3.6.4111459/bin/cmake with arguments {--build /home/VICOMTECH/uelordi/projects/SwitchTrackingEngine/kanvas_tracker/kt/tools/Deep-learning-tools/android/tfliteTest/app/.externalNativeBuild/cmake/debug/armeabi-v7a --target native-lib}\r\n[1/1] Linking CXX shared library ../../../../build/intermediates/cmake/debug/obj/armeabi-v7a/libnative-lib.so\r\nFAILED: : && /home/VICOMTECH/uelordi/SDK/android-ndk-r16b/toolchains/llvm/prebuilt/linux-x86_64/bin/clang++  --target=armv7-none-linux-androideabi --gcc-toolchain=/home/VICOMTECH/uelordi/SDK/android-ndk-r16b/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64 --sysroot=/home/VICOMTECH/uelordi/SDK/android-ndk-r16b/sysroot -fPIC -isystem /home/VICOMTECH/uelordi/SDK/android-ndk-r16b/sysroot/usr/include/arm-linux-androideabi -D__ANDROID_API__=21 -g -DANDROID -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -march=armv7-a -mfloat-abi=softfp -mfpu=vfpv3-d16 -fno-integrated-as -mthumb -Wa,--noexecstack -Wformat -Werror=format-security  -std=c++11 -O0 -fno-limit-debug-info  -Wl,--exclude-libs,libgcc.a -Wl,--exclude-libs,libatomic.a --sysroot /home/VICOMTECH/uelordi/SDK/android-ndk-r16b/platforms/android-21/arch-arm -Wl,--build-id -Wl,--warn-shared-textrel -Wl,--fatal-warnings -Wl,--fix-cortex-a8 -Wl,--no-undefined -Wl,-z,noexecstack -Qunused-arguments -Wl,-z,relro -Wl,-z,now -shared -Wl,-soname,libnative-lib.so -o ../../../../build/intermediates/cmake/debug/obj/armeabi-v7a/libnative-lib.so CMakeFiles/native-lib.dir/src/main/cpp/native-lib.cpp.o  /home/VICOMTECH/uelordi/SDK/tensorflow/tensorflow/contrib/lite/gen/lib/libtensorflow-lite.a /home/VICOMTECH/uelordi/SDK/android-ndk-r16b/platforms/android-21/arch-arm/usr/lib/liblog.so -latomic -lm \"/home/VICOMTECH/uelordi/SDK/android-ndk-r16b/sources/cxx-stl/gnu-libstdc++/4.9/libs/armeabi-v7a/libgnustl_static.a\" && :\r\n/home/VICOMTECH/uelordi/SDK/android-ndk-r16b/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/lib/gcc/arm-linux-androideabi/4.9.x/../../../../arm-linux-androideabi/bin/ld: error: /home/VICOMTECH/uelordi/SDK/tensorflow/tensorflow/contrib/lite/gen/lib/libtensorflow-lite.a(error_reporter.o): incompatible target\r\n/home/VICOMTECH/uelordi/SDK/android-ndk-r16b/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/lib/gcc/arm-linux-androideabi/4.9.x/../../../../arm-linux-androideabi/bin/ld: error: /home/VICOMTECH/uelordi/SDK/tensorflow/tensorflow/contrib/lite/gen/lib/libtensorflow-lite.a(interpreter.o): incompatible target\r\n/home/VICOMTECH/uelordi/SDK/android-ndk-r16b/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/lib/gcc/arm-linux-androideabi/4.9.x/../../../../arm-linux-androideabi/bin/ld: error: /home/VICOMTECH/uelordi/SDK/tensorflow/tensorflow/contrib/lite/gen/lib/libtensorflow-lite.a(register.o): incompatible target\r\n/home/VICOMTECH/uelordi/SDK/android-ndk-r16b/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/lib/gcc/arm-linux-androideabi/4.9.x/../../../../arm-linux-androideabi/bin/ld: error: /home/VICOMTECH/uelordi/SDK/tensorflow/tensorflow/contrib/lite/gen/lib/libtensorflow-lite.a(model.o): incompatible target\r\n/home/VICOMTECH/uelordi/SDK/android-ndk-r16b/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/lib/gcc/arm-linux-androideabi/4.9.x/../../../../arm-linux-androideabi/bin/ld: error: /home/VICOMTECH/uelordi/SDK/tensorflow/tensorflow/contrib/lite/gen/lib/libtensorflow-lite.a(op_resolver.o): incompatible target\r\n/home/VICOMTECH/uelordi/projects/SwitchTrackingEngine/kanvas_tracker/kt/tools/Deep-learning-tools/android/tfliteTest/app/src/main/cpp/native-lib.cpp:23: error: undefined reference to 'tflite::DefaultErrorReporter()'\r\n/home/VICOMTECH/uelordi/projects/SwitchTrackingEngine/kanvas_tracker/kt/tools/Deep-learning-tools/android/tfliteTest/app/src/main/cpp/native-lib.cpp:23: error: undefined reference to 'tflite::FlatBufferModel::BuildFromFile(char const*, tflite::ErrorReporter*)'\r\n/home/VICOMTECH/uelordi/projects/SwitchTrackingEngine/kanvas_tracker/kt/tools/Deep-learning-tools/android/tfliteTest/app/src/main/cpp/native-lib.cpp:27: error: undefined reference to 'tflite::ops::builtin::BuiltinOpResolver::BuiltinOpResolver()'\r\n/home/VICOMTECH/uelordi/projects/SwitchTrackingEngine/kanvas_tracker/kt/tools/Deep-learning-tools/android/tfliteTest/app/src/main/cpp/native-lib.cpp:28: error: undefined reference to 'tflite::InterpreterBuilder::InterpreterBuilder(tflite::FlatBufferModel const&, tflite::OpResolver const&)'\r\n/home/VICOMTECH/uelordi/projects/SwitchTrackingEngine/kanvas_tracker/kt/tools/Deep-learning-tools/android/tfliteTest/app/src/main/cpp/native-lib.cpp:30: error: undefined reference to 'tflite::InterpreterBuilder::operator()(std::unique_ptr<tflite::Interpreter, std::default_delete<tflite::Interpreter> >*)'\r\n/home/VICOMTECH/uelordi/SDK/tensorflow/tensorflow/contrib/lite/op_resolver.h:70: error: undefined reference to 'vtable for tflite::MutableOpResolver'\r\n/home/VICOMTECH/uelordi/SDK/android-ndk-r16b/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/lib/gcc/arm-linux-androideabi/4.9.x/../../../../arm-linux-androideabi/bin/ld: the vtable symbol may be undefined because the class is missing its key function\r\n/home/VICOMTECH/uelordi/SDK/android-ndk-r16b/sources/cxx-stl/gnu-libstdc++/4.9/include/bits/unique_ptr.h:76: error: undefined reference to 'tflite::FlatBufferModel::~FlatBufferModel()'\r\n/home/VICOMTECH/uelordi/SDK/android-ndk-r16b/sources/cxx-stl/gnu-libstdc++/4.9/include/bits/unique_ptr.h:76: error: undefined reference to 'tflite::Interpreter::~Interpreter()'\r\nclang++: error: linker command failed with exit code 1 (use -v to see invocation)\r\nninja: build stopped: subcommand failed.\r\n```\r\n\r\n\r\nMy CmakeScript: \r\n```\r\n# For more information about using CMake with Android Studio, read the\r\n# documentation: https://d.android.com/studio/projects/add-native-code.html\r\n\r\n# Sets the minimum version of CMake required to build the native library.\r\n`\r\nSET(PROJECT_NAME  native-lib)\r\ncmake_minimum_required(VERSION 3.4.1)\r\nset(PREBUILT_DIR ${TENSORFLOW_ROOT_DIR}/tensorflow/contrib/lite)\r\n\r\nadd_library(lib_tflite STATIC IMPORTED )\r\nset_target_properties(lib_tflite PROPERTIES IMPORTED_LOCATION\r\n${PREBUILT_DIR}/gen/lib/libtensorflow-lite.a)\r\n\r\nINCLUDE_DIRECTORIES(${TENSORFLOW_ROOT_DIR}\r\n    ${PREBUILT_DIR}/downloads/flatbuffers/include)\r\n\r\nadd_library( # Sets the name of the library.\r\n            ${PROJECT_NAME}\r\n             SHARED\r\n             src/main/cpp/native-lib.cpp )\r\n\r\nfind_library( log-lib\r\n              log )\r\n\r\n\r\ntarget_link_libraries( # Specifies the target library.\r\n                       ${PROJECT_NAME}\r\n                       lib_tflite\r\n                       ${log-lib} )\r\n```\r\n\r\n\r\n\r\nMy build_gradle (I have only copy the relevant part)\r\n```\r\nandroid {\r\n    compileSdkVersion 27\r\n    defaultConfig {\r\n        applicationId \"com.androidapp.kt.kanvas.tflitetest\"\r\n        minSdkVersion 21\r\n        targetSdkVersion 27\r\n        versionCode 1\r\n        versionName \"1.0\"\r\n        testInstrumentationRunner \"android.support.test.runner.AndroidJUnitRunner\"\r\n        externalNativeBuild {\r\n            cmake {\r\n                cppFlags \"-std=c++11\"\r\n                arguments \"-DTENSORFLOW_ROOT_DIR=\" + getTensorflowDir().toString()\r\n                abiFilters  'armeabi-v7a' \r\n            }\r\n        }\r\n    }\r\n```\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/tensorflow/tensorflow/issues/comments/437299825","html_url":"https://github.com/tensorflow/tensorflow/issues/19642#issuecomment-437299825","issue_url":"https://api.github.com/repos/tensorflow/tensorflow/issues/19642","id":437299825,"node_id":"MDEyOklzc3VlQ29tbWVudDQzNzI5OTgyNQ==","user":{"login":"zhyj3038","id":14101478,"node_id":"MDQ6VXNlcjE0MTAxNDc4","avatar_url":"https://avatars3.githubusercontent.com/u/14101478?v=4","gravatar_id":"","url":"https://api.github.com/users/zhyj3038","html_url":"https://github.com/zhyj3038","followers_url":"https://api.github.com/users/zhyj3038/followers","following_url":"https://api.github.com/users/zhyj3038/following{/other_user}","gists_url":"https://api.github.com/users/zhyj3038/gists{/gist_id}","starred_url":"https://api.github.com/users/zhyj3038/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zhyj3038/subscriptions","organizations_url":"https://api.github.com/users/zhyj3038/orgs","repos_url":"https://api.github.com/users/zhyj3038/repos","events_url":"https://api.github.com/users/zhyj3038/events{/privacy}","received_events_url":"https://api.github.com/users/zhyj3038/received_events","type":"User","site_admin":false},"created_at":"2018-11-09T09:21:40Z","updated_at":"2018-11-09T09:21:40Z","author_association":"NONE","body":"just add\r\n\r\ncc_binary(\r\nname = \"libtensorflowLite.so\",\r\n\r\nlinkopts=[\"-shared\", \"-Wl\"],\r\nlinkshared=1,\r\n\r\ncopts = tflite_copts(),\r\ndeps = [\r\n    \":framework\",\r\n    \"//tensorflow/contrib/lite/kernels:builtin_ops\",\r\n],\r\n\r\nto any positon of tensorflow's BUILD file. the BUILD file is in tensorflow's root folder"}}
{"actor":{"display_login":"zhyj3038"}}