Can not build android_rpc

I try to build android_rpc ,my tvm version is 0.7.dev1

cd apps/android_rpc

gradle clean build

But got error like:

Task :app:buildJni FAILED FAILURE: Build failed with an exception. What went wrong: Execution failed for task ‘:app:buildJni’. Process ‘command ‘sh’’ finished with non-zero exit value 2

I find apps/android_rpc/app/src/main/jni/build.sh will run :

PATH="$PATH:/usr/local/bin"

CURR_DIR=$(cd dirname $0; pwd)

ROOT_DIR="$CURR_DIR/…/…/…/…/…/…"

javah -o $CURR_DIR/org_apache_tvm_native_c_api.h -cp “$ROOT_DIR/jvm/core/target/*”

org.apache.tvm.LibInfo || exit -1

cp -f $ROOT_DIR/jvm/native/src/main/native/org_apache_tvm_native_c_api.cc $CURR_DIR/ || exit -1

cp -f $ROOT_DIR/jvm/native/src/main/native/jni_helper_func.h $CURR_DIR/ || exit -1

rm -rf $CURR_DIR/…/libs

ndk-build --directory=$CURR_DIR

ndk-build --directory=$CURR_DIR will return error :

make: Entering directory /workspace/apps/android_rpc/app/src/main/jni' [arm64-v8a] SharedLibrary : libtvm4j_runtime_packed.so /workspace/apps/android_rpc/app/src/main/obj/local/arm64-v8a/objs/tvm4j_runtime_packed/org_apache_tvm_native_c_api.o: In function tvm::runtime::CreateEventDrivenServer(tvm::runtime::PackedFunc, std::__ndk1::basic_string<char, std::__ndk1::char_traits, std::__ndk1::allocator >, std::__ndk1::basic_string<char, std::__ndk1::char_traits, std::__ndk1::allocator >)’: /workspace/apps/android_rpc/app/src/main/jni/…/…/…/…/…/…/include/…/src/runtime/rpc/rpc_event_impl.cc:41: undefined reference to tvm::runtime::RPCEndpoint::Create(std::__ndk1::unique_ptr<tvm::runtime::RPCChannel, std::__ndk1::default_delete<tvm::runtime::RPCChannel> >, std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> >, std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> >)' /workspace/apps/android_rpc/app/src/main/obj/local/arm64-v8a/objs/tvm4j_runtime_packed/org_apache_tvm_native_c_api.o: In function CallbackChannel’: /workspace/apps/android_rpc/app/src/main/jni/…/…/…/…/…/…/include/…/src/runtime/rpc/rpc_channel.h:73: undefined reference to vtable for tvm::runtime::CallbackChannel' /workspace/apps/android_rpc/app/src/main/jni/../../../../../../include/../src/runtime/rpc/rpc_channel.h:73: undefined reference to vtable for tvm::runtime::CallbackChannel’ /workspace/apps/android_rpc/app/src/main/obj/local/arm64-v8a/objs/tvm4j_runtime_packed/org_apache_tvm_native_c_api.o: In function tvm::runtime::RPCConnect(std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> >, int, std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> >, tvm::runtime::TVMArgs)': /workspace/apps/android_rpc/app/src/main/jni/../../../../../../include/../src/runtime/rpc/rpc_socket_impl.cc:101: undefined reference to tvm::runtime::RPCEndpoint::Create(std::__ndk1::unique_ptr<tvm::runtime::RPCChannel, std::__ndk1::default_deletetvm::runtime::RPCChannel >, std::__ndk1::basic_string<char, std::__ndk1::char_traits, std::__ndk1::allocator >, std::__ndk1::basic_string<char, std::__ndk1::char_traits, std::__ndk1::allocator >)’ /workspace/apps/android_rpc/app/src/main/jni/…/…/…/…/…/…/include/…/src/runtime/rpc/rpc_socket_impl.cc:102: undefined reference to tvm::runtime::RPCEndpoint::InitRemoteSession(tvm::runtime::TVMArgs)' /workspace/apps/android_rpc/app/src/main/obj/local/arm64-v8a/objs/tvm4j_runtime_packed/org_apache_tvm_native_c_api.o: In function tvm::runtime::RPCClientConnect(std::__ndk1::basic_string<char, std::__ndk1::char_traits, std::__ndk1::allocator >, int, std::__ndk1::basic_string<char, std::__ndk1::char_traits, std::__ndk1::allocator >, tvm::runtime::TVMArgs)’: /workspace/apps/android_rpc/app/src/main/jni/…/…/…/…/…/…/include/…/src/runtime/rpc/rpc_socket_impl.cc:108: undefined reference to tvm::runtime::CreateClientSession(std::__ndk1::shared_ptr<tvm::runtime::RPCEndpoint>)' /workspace/apps/android_rpc/app/src/main/obj/local/arm64-v8a/objs/tvm4j_runtime_packed/org_apache_tvm_native_c_api.o: In function tvm::runtime::RPCServerLoop(int)’: /workspace/apps/android_rpc/app/src/main/jni/…/…/…/…/…/…/include/…/src/runtime/rpc/rpc_socket_impl.cc:114: undefined reference to tvm::runtime::RPCEndpoint::Create(std::__ndk1::unique_ptr<tvm::runtime::RPCChannel, std::__ndk1::default_delete<tvm::runtime::RPCChannel> >, std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> >, std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> >)' /workspace/apps/android_rpc/app/src/main/jni/../../../../../../include/../src/runtime/rpc/rpc_socket_impl.cc:115: undefined reference to tvm::runtime::RPCEndpoint::ServerLoop()’ /workspace/apps/android_rpc/app/src/main/obj/local/arm64-v8a/objs/tvm4j_runtime_packed/org_apache_tvm_native_c_api.o: In function tvm::runtime::RPCServerLoop(tvm::runtime::PackedFunc, tvm::runtime::PackedFunc)': /workspace/apps/android_rpc/app/src/main/jni/../../../../../../include/../src/runtime/rpc/rpc_socket_impl.cc:119: undefined reference to tvm::runtime::RPCEndpoint::Create(std::__ndk1::unique_ptr<tvm::runtime::RPCChannel, std::__ndk1::default_deletetvm::runtime::RPCChannel >, std::__ndk1::basic_string<char, std::__ndk1::char_traits, std::__ndk1::allocator >, std::__ndk1::basic_string<char, std::__ndk1::char_traits, std::__ndk1::allocator >)’ /workspace/apps/android_rpc/app/src/main/jni/…/…/…/…/…/…/include/…/src/runtime/rpc/rpc_socket_impl.cc:121: undefined reference to tvm::runtime::RPCEndpoint::ServerLoop()' /workspace/apps/android_rpc/app/src/main/obj/local/arm64-v8a/objs/tvm4j_runtime_packed/org_apache_tvm_native_c_api.o: In function operator()’: /workspace/apps/android_rpc/app/src/main/jni/…/…/…/…/…/…/include/…/src/runtime/rpc/rpc_event_impl.cc:43: undefined reference to tvm::runtime::RPCEndpoint::ServerAsyncIOEventHandler(std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> > const&, int)' clang++: error: linker command failed with exit code 1 (use -v to see invocation) make: *** [/workspace/apps/android_rpc/app/src/main/obj/local/arm64-v8a/libtvm4j_runtime_packed.so] Error 1 make: Leaving directory /workspace/apps/android_rpc/app/src/main/jni’

You can use this way to avoid it: in tvm/apps/android_rpc/app/src/main/jni/make/config.mk modify : APP_ABI = all to APP_ABI = armeabi-v7a #choise your android abi in (armeabi-v7a arm64-v8a x86 x86_64 mips) And at the last line: ADD_LDLIBS = /home/tvm/apps/android_rpc/app/src/main/jni/libtvm_runtime.so #make by cross compile Then try it again, you may success

You can try this way:

apps/android_rpc/app/src/main/jni/Android.mk: Line 36

LOCAL_SRC_FILES := org_apache_tvm_native_c_api.cc

modify:

LOCAL_SRC_FILES := org_apache_tvm_native_c_api.cc \
					$(ROOT_PATH)/src/runtime/rpc/rpc_channel.cc \
					$(ROOT_PATH)/src/runtime/rpc/rpc_endpoint.cc \
					$(ROOT_PATH)/src/runtime/rpc/rpc_local_session.cc

This is my solution