Repository: pytorch
Issue: link failed when using custom build pytorch on Android
Labels: triaged,module: undefined reference,module: android,module: arm


Hello , I got a problem when used custom build pytorch on Android device. And the errors are as following:
FAILED: ../../../../build/intermediates/cmake/debug/obj/arm64-v8a/libocrKit.so 
: && /Users/peter/Library/Android/sdk/ndk-bundle/toolchains/llvm/prebuilt/darwin-x86_64/bin/clang++ --target=aarch64-none-linux-android21 --gcc-toolchain=/Users/peter/Library/Android/sdk/ndk-bundle/toolchains/llvm/prebuilt/darwin-x86_64 --sysroot=/Users/peter/Library/Android/sdk/ndk-bundle/toolchains/llvm/prebuilt/darwin-x86_64/sysroot -fPIC -g -DANDROID -fdata-sections -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -fno-addrsig -Wa,--noexecstack -Wformat -Werror=format-security   -std=c++14 -O3 -O0 -fno-limit-debug-info  -Wl,--exclude-libs,libgcc.a -Wl,--exclude-libs,libatomic.a -static-libstdc++ -Wl,--build-id -Wl,--warn-shared-textrel -Wl,--fatal-warnings -Wl,--no-undefined -Qunused-arguments -Wl,-z,noexecstack -shared -Wl,-soname,libocrKit.so -o ../../../../build/intermediates/cmake/debug/obj/arm64-v8a/libocrKit.so CMakeFiles/ocrKit.dir/src/main/cpp/ocr_kit_jni.cpp.o CMakeFiles/ocrKit.dir/src/main/cpp/jni_helper.cpp.o  ocrpro.a ../../../../libs/arm64-v8a/libpytorch_jni.so ../../../../libs/arm64-v8a/libfbjni.so ../../../../libs/arm64-v8a/libpaperlog.so ../../../../libs/arm64-v8a/libcrypt.so -latomic -lm && :
ocrpro.a(paper_ocr_kit.cpp.o): In function `paper::RecognizeChar(void*, std::__ndk1::vector<unsigned char, std::__ndk1::allocator<unsigned char> > const&, int, int, float&, std::__ndk1::vector<int, std::__ndk1::allocator<int> >&, std::__ndk1::vector<float, std::__ndk1::allocator<float> >&)':
/Users/peter/paper/OCRRoot/src/paper_ocr_kit.cpp:252: undefined reference to `float* at::Tensor::data_ptr<float>() const'
/Users/peter/paper/OCRRoot/src/paper_ocr_kit.cpp:259: undefined reference to `at::topk(at::Tensor const&, long, long, bool, bool)'
/Users/peter/paper/OCRRoot/src/paper_ocr_kit.cpp:264: undefined reference to `float* at::Tensor::data_ptr<float>() const'
/Users/peter/paper/OCRRoot/src/paper_ocr_kit.cpp:275: undefined reference to `long* at::Tensor::data_ptr<long>() const'
ocrpro.a(paper_ocr_kit.cpp.o): In function `c10::UndefinedTensorImpl::singleton()':
/Users/peter/paper/OCRRoot/pytorch_headers/c10/core/UndefinedTensorImpl.h:18: undefined reference to `c10::UndefinedTensorImpl::_singleton'
/Users/peter/paper/OCRRoot/pytorch_headers/c10/core/UndefinedTensorImpl.h:18: undefined reference to `c10::UndefinedTensorImpl::_singleton'
ocrpro.a(paper_ocr_kit.cpp.o): In function `c10::intrusive_ptr<c10::TensorImpl, c10::UndefinedTensorImpl>::retain_()':
/Users/peter/paper/OCRRoot/pytorch_headers/c10/util/intrusive_ptr.h:188: undefined reference to `c10::Error::Error(c10::SourceLocation, std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> >)'
ocrpro.a(paper_ocr.cpp.o): In function `ocrHandle':
/Users/peter/paper/OCRRoot/src/paper_ocr.cpp:147: undefined reference to `torch::jit::load(std::__ndk1::basic_istream<char, std::__ndk1::char_traits<char> >&, c10::optional<c10::Device>, std::__ndk1::unordered_map<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> >, std::__ndk1::hash<std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> > >, std::__ndk1::equal_to<std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> > >, std::__ndk1::allocator<std::__ndk1::pair<std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> > const, std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> > > > >&)'
ocrpro.a(paper_ocr.cpp.o): In function `torch::jit::Module::eval()':
/Users/peter/paper/OCRRoot/pytorch_headers/torch/csrc/jit/api/module.h:183: undefined reference to `torch::jit::Module::train(bool)'
ocrpro.a(paper_ocr.cpp.o): In function `AutoGradMode':
/Users/peter/paper/OCRRoot/pytorch_headers/ATen/core/grad_mode.h:15: undefined reference to `at::GradMode::is_enabled()'
/Users/peter/paper/OCRRoot/pytorch_headers/ATen/core/grad_mode.h:16: undefined reference to `at::GradMode::set_enabled(bool)'
ocrpro.a(paper_ocr.cpp.o): In function `AutoNonVariableTypeMode':
/Users/peter/paper/OCRRoot/pytorch_headers/ATen/core/LegacyTypeDispatch.h:50: undefined reference to `c10::impl::ExcludeDispatchKeyGuard::ExcludeDispatchKeyGuard(c10::DispatchKey)'
/Users/peter/paper/OCRRoot/pytorch_headers/ATen/core/LegacyTypeDispatch.h:52: undefined reference to `c10::Error::Error(c10::SourceLocation, std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> >)'
/Users/peter/paper/OCRRoot/pytorch_headers/ATen/core/LegacyTypeDispatch.h:53: undefined reference to `c10::impl::ExcludeDispatchKeyGuard::~ExcludeDispatchKeyGuard()'
ocrpro.a(paper_ocr.cpp.o): In function `torch::jit::Module::forward(std::__ndk1::vector<c10::IValue, std::__ndk1::allocator<c10::IValue> >)':
/Users/peter/paper/OCRRoot/pytorch_headers/torch/csrc/jit/api/module.h:112: undefined reference to `torch::jit::Method::operator()(std::__ndk1::vector<c10::IValue, std::__ndk1::allocator<c10::IValue> >, std::__ndk1::unordered_map<std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> >, c10::IValue, std::__ndk1::hash<std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> > >, std::__ndk1::equal_to<std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> > >, std::__ndk1::allocator<std::__ndk1::pair<std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> > const, c10::IValue> > > const&)'
ocrpro.a(paper_ocr.cpp.o): In function `c10::IValue::toTensor() &&':
/Users/peter/paper/OCRRoot/pytorch_headers/ATen/core/ivalue_inl.h:107: undefined reference to `c10::Error::Error(c10::SourceLocation, std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> >)'
ocrpro.a(paper_ocr.cpp.o): In function `~AutoNonVariableTypeMode':
/Users/peter/paper/OCRRoot/pytorch_headers/ATen/core/LegacyTypeDispatch.h:46: undefined reference to `c10::impl::ExcludeDispatchKeyGuard::~ExcludeDispatchKeyGuard()'
ocrpro.a(paper_ocr.cpp.o): In function `~AutoGradMode':
/Users/peter/paper/OCRRoot/pytorch_headers/ATen/core/grad_mode.h:19: undefined reference to `at::GradMode::set_enabled(bool)'
ocrpro.a(paper_ocr.cpp.o): In function `c10::intrusive_ptr<c10::ivalue::Object, c10::detail::intrusive_target_default_null_type<c10::ivalue::Object> >::retain_()':
/Users/peter/paper/OCRRoot/pytorch_headers/c10/util/intrusive_ptr.h:188: undefined reference to `c10::Error::Error(c10::SourceLocation, std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> >)'
ocrpro.a(paper_ocr.cpp.o): In function `torch::autograd::make_variable(at::Tensor, bool, bool)':
/Users/peter/paper/OCRRoot/pytorch_headers/torch/csrc/autograd/variable.h:496: undefined reference to `c10::TensorImpl::set_autograd_meta(std::__ndk1::unique_ptr<c10::AutogradMetaInterface, std::__ndk1::default_delete<c10::AutogradMetaInterface> >)'
/Users/peter/paper/OCRRoot/pytorch_headers/torch/csrc/autograd/variable.h:498: undefined reference to `c10::TensorImpl::set_autograd_meta(std::__ndk1::unique_ptr<c10::AutogradMetaInterface, std::__ndk1::default_delete<c10::AutogradMetaInterface> >)'
/Users/peter/paper/OCRRoot/pytorch_headers/torch/csrc/autograd/variable.h:506: undefined reference to `c10::TensorImpl::set_autograd_meta(std::__ndk1::unique_ptr<c10::AutogradMetaInterface, std::__ndk1::default_delete<c10::AutogradMetaInterface> >)'
/Users/peter/paper/OCRRoot/pytorch_headers/torch/csrc/autograd/variable.h:509: undefined reference to `c10::TensorImpl::set_autograd_meta(std::__ndk1::unique_ptr<c10::AutogradMetaInterface, std::__ndk1::default_delete<c10::AutogradMetaInterface> >)'
ocrpro.a(paper_ocr.cpp.o): In function `NoTracerDispatchMode':
/Users/peter/paper/OCRRoot/pytorch_headers/ATen/TracerMode.h:129: undefined reference to `c10::impl::ExcludeDispatchKeyGuard::ExcludeDispatchKeyGuard(c10::DispatchKey)'
ocrpro.a(paper_ocr.cpp.o): In function `at::from_blob(void*, c10::ArrayRef<long>, c10::TensorOptions const&)':
/Users/peter/paper/OCRRoot/pytorch_headers/ATen/Functions.h:1336: undefined reference to `at::detail::defaultStrides(c10::ArrayRef<long>)'
ocrpro.a(paper_ocr.cpp.o): In function `~NoTracerDispatchMode':
/Users/peter/paper/OCRRoot/pytorch_headers/ATen/TracerMode.h:128: undefined reference to `c10::impl::ExcludeDispatchKeyGuard::~ExcludeDispatchKeyGuard()'
ocrpro.a(paper_ocr.cpp.o): In function `at::from_blob(void*, c10::ArrayRef<long>, c10::ArrayRef<long>, c10::TensorOptions const&)':
/Users/peter/paper/OCRRoot/pytorch_headers/ATen/Functions.h:1316: undefined reference to `at::globalContext()'
/Users/peter/paper/OCRRoot/pytorch_headers/ATen/Functions.h:1318: undefined reference to `c10::Error::Error(c10::SourceLocation, std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> >)'
/Users/peter/paper/OCRRoot/pytorch_headers/ATen/Functions.h:1325: undefined reference to `at::detail::computeStorageNbytes(c10::ArrayRef<long>, c10::ArrayRef<long>, unsigned long)'
/Users/peter/paper/OCRRoot/pytorch_headers/ATen/Functions.h:1329: undefined reference to `at::empty(c10::ArrayRef<long>, c10::TensorOptions const&, c10::optional<c10::MemoryFormat>)'
/Users/peter/paper/OCRRoot/pytorch_headers/ATen/Functions.h:1329: undefined reference to `at::Tensor::set_(c10::Storage, long, c10::ArrayRef<long>, c10::ArrayRef<long>) const'
ocrpro.a(paper_ocr.cpp.o): In function `at::Context::getDeviceFromPtr(void*, c10::DeviceType)':
/Users/peter/paper/OCRRoot/pytorch_headers/ATen/Context.h:46: undefined reference to `at::detail::getCUDAHooks()'
/Users/peter/paper/OCRRoot/pytorch_headers/ATen/Context.h:48: undefined reference to `c10::DeviceTypeName(c10::DeviceType, bool)'
/Users/peter/paper/OCRRoot/pytorch_headers/ATen/Context.h:48: undefined reference to `c10::Error::Error(c10::SourceLocation, std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> >)'
ocrpro.a(paper_ocr.cpp.o): In function `c10::TensorOptions::dtype() const':
/Users/peter/paper/OCRRoot/pytorch_headers/c10/core/TensorOptions.h:252: undefined reference to `c10::get_default_dtype()'
ocrpro.a(paper_ocr.cpp.o): In function `operator()':
/Users/peter/paper/OCRRoot/pytorch_headers/ATen/Context.h:74: undefined reference to `at::detail::getCUDAHooks()'
/Users/peter/paper/OCRRoot/pytorch_headers/ATen/Context.h:80: undefined reference to `at::detail::getHIPHooks()'
ocrpro.a(paper_ocr.cpp.o): In function `c10::Device::validate()':
/Users/peter/paper/OCRRoot/pytorch_headers/c10/core/Device.h:96: undefined reference to `c10::Error::Error(c10::SourceLocation, std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> >)'
/Users/peter/paper/OCRRoot/pytorch_headers/c10/core/Device.h:98: undefined reference to `c10::Error::Error(c10::SourceLocation, std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> >)'
ocrpro.a(paper_ocr.cpp.o): In function `std::__ndk1::basic_ostream<char, std::__ndk1::char_traits<char> >& c10::detail::_str<c10::Device>(std::__ndk1::basic_ostream<char, std::__ndk1::char_traits<char> >&, c10::Device const&)':
/Users/peter/paper/OCRRoot/pytorch_headers/c10/util/StringUtil.h:37: undefined reference to `c10::operator<<(std::__ndk1::basic_ostream<char, std::__ndk1::char_traits<char> >&, c10::Device const&)'
ocrpro.a(paper_ocr.cpp.o): In function `UniqueVoidPtr':
/Users/peter/paper/OCRRoot/pytorch_headers/c10/util/UniqueVoidPtr.h:(.text._ZN3c106detail13UniqueVoidPtrC2EPvS2_PFvS2_E[_ZN3c106detail13UniqueVoidPtrC2EPvS2_PFvS2_E]+0x58): undefined reference to `c10::detail::deleteNothing(void*)'
/Users/peter/paper/OCRRoot/pytorch_headers/c10/util/UniqueVoidPtr.h:(.text._ZN3c106detail13UniqueVoidPtrC2EPvS2_PFvS2_E[_ZN3c106detail13UniqueVoidPtrC2EPvS2_PFvS2_E]+0x5c): undefined reference to `c10::detail::deleteNothing(void*)'
ocrpro.a(paper_ocr.cpp.o): In function `StorageImpl':
/Users/peter/paper/OCRRoot/pytorch_headers/c10/core/StorageImpl.h:26: undefined reference to `c10::Error::Error(c10::SourceLocation, std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> >)'
ocrpro.a(paper_ocr.cpp.o): In function `~intrusive_ptr_target':
/Users/peter/paper/OCRRoot/pytorch_headers/c10/util/intrusive_ptr.h:96: undefined reference to `c10::Error::Error(c10::SourceLocation, std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> >)'
/Users/peter/paper/OCRRoot/pytorch_headers/c10/util/intrusive_ptr.h:99: undefined reference to `c10::Error::Error(c10::SourceLocation, std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> >)'
ocrpro.a(paper_ocr.cpp.o): In function `c10::intrusive_ptr<c10::StorageImpl, c10::detail::intrusive_target_default_null_type<c10::StorageImpl> >::retain_()':
/Users/peter/paper/OCRRoot/pytorch_headers/c10/util/intrusive_ptr.h:188: undefined reference to `c10::Error::Error(c10::SourceLocation, std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> >)'
ocrpro.a(paper_ocr.cpp.o): In function `AutogradMeta':
/Users/peter/paper/OCRRoot/pytorch_headers/torch/csrc/autograd/variable.h:250: undefined reference to `c10::Error::Error(c10::SourceLocation, std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> >)'
ocrpro.a(paper_ocr.cpp.o):/Users/peter/paper/OCRRoot/pytorch_headers/torch/csrc/autograd/variable.h:253: more undefined references to `c10::Error::Error(c10::SourceLocation, std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> >)' follow
ocrpro.a(paper_ocr.cpp.o): In function `AutogradMeta':
/Users/peter/paper/OCRRoot/pytorch_headers/torch/csrc/autograd/variable.h:256: undefined reference to `c10::AutogradMetaInterface::~AutogradMetaInterface()'
ocrpro.a(paper_ocr.cpp.o): In function `AutogradMetaInterface':
/Users/peter/paper/OCRRoot/pytorch_headers/c10/core/TensorImpl.h:134: undefined reference to `vtable for c10::AutogradMetaInterface'
/Users/peter/paper/OCRRoot/pytorch_headers/c10/core/TensorImpl.h:134: undefined reference to `vtable for c10::AutogradMetaInterface'
ocrpro.a(paper_ocr.cpp.o): In function `torch::autograd::AutogradMeta::set_requires_grad(bool, c10::TensorImpl*)':
/Users/peter/paper/OCRRoot/pytorch_headers/torch/csrc/autograd/variable.h:222: undefined reference to `c10::Error::Error(c10::SourceLocation, std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> >)'
ocrpro.a(paper_ocr.cpp.o): In function `~AutogradMeta':
/Users/peter/paper/OCRRoot/pytorch_headers/torch/csrc/autograd/variable.h:189: undefined reference to `c10::AutogradMetaInterface::~AutogradMetaInterface()'
ocrpro.a(paper_ocr.cpp.o): In function `c10::typeMetaToScalarType(caffe2::TypeMeta)':
/Users/peter/paper/OCRRoot/pytorch_headers/c10/core/ScalarType.h:185: undefined reference to `c10::Error::Error(c10::SourceLocation, std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> >)'
ocrpro.a(paper_ocr.cpp.o): In function `caffe2::TypeMeta caffe2::TypeMeta::Make<unsigned char>()':
/Users/peter/paper/OCRRoot/pytorch_headers/c10/util/typeid.h:439: undefined reference to `caffe2::detail::TypeMetaData const* caffe2::TypeMeta::_typeMetaDataInstance<unsigned char>()'
ocrpro.a(paper_ocr.cpp.o): In function `caffe2::TypeMeta caffe2::TypeMeta::Make<signed char>()':
/Users/peter/paper/OCRRoot/pytorch_headers/c10/util/typeid.h:439: undefined reference to `caffe2::detail::TypeMetaData const* caffe2::TypeMeta::_typeMetaDataInstance<signed char>()'
ocrpro.a(paper_ocr.cpp.o): In function `caffe2::TypeMeta caffe2::TypeMeta::Make<short>()':
/Users/peter/paper/OCRRoot/pytorch_headers/c10/util/typeid.h:439: undefined reference to `caffe2::detail::TypeMetaData const* caffe2::TypeMeta::_typeMetaDataInstance<short>()'
ocrpro.a(paper_ocr.cpp.o): In function `caffe2::TypeMeta caffe2::TypeMeta::Make<int>()':
/Users/peter/paper/OCRRoot/pytorch_headers/c10/util/typeid.h:439: undefined reference to `caffe2::detail::TypeMetaData const* caffe2::TypeMeta::_typeMetaDataInstance<int>()'
ocrpro.a(paper_ocr.cpp.o): In function `caffe2::TypeMeta caffe2::TypeMeta::Make<long>()':
/Users/peter/paper/OCRRoot/pytorch_headers/c10/util/typeid.h:439: undefined reference to `caffe2::detail::TypeMetaData const* caffe2::TypeMeta::_typeMetaDataInstance<long>()'
ocrpro.a(paper_ocr.cpp.o): In function `caffe2::TypeMeta caffe2::TypeMeta::Make<c10::Half>()':
/Users/peter/paper/OCRRoot/pytorch_headers/c10/util/typeid.h:439: undefined reference to `caffe2::detail::TypeMetaData const* caffe2::TypeMeta::_typeMetaDataInstance<c10::Half>()'
ocrpro.a(paper_ocr.cpp.o): In function `caffe2::TypeMeta caffe2::TypeMeta::Make<float>()':
/Users/peter/paper/OCRRoot/pytorch_headers/c10/util/typeid.h:439: undefined reference to `caffe2::detail::TypeMetaData const* caffe2::TypeMeta::_typeMetaDataInstance<float>()'
ocrpro.a(paper_ocr.cpp.o): In function `caffe2::TypeMeta caffe2::TypeMeta::Make<double>()':
/Users/peter/paper/OCRRoot/pytorch_headers/c10/util/typeid.h:439: undefined reference to `caffe2::detail::TypeMetaData const* caffe2::TypeMeta::_typeMetaDataInstance<double>()'
ocrpro.a(paper_ocr.cpp.o): In function `caffe2::TypeMeta caffe2::TypeMeta::Make<c10::complex<c10::Half> >()':
/Users/peter/paper/OCRRoot/pytorch_headers/c10/util/typeid.h:439: undefined reference to `caffe2::detail::TypeMetaData const* caffe2::TypeMeta::_typeMetaDataInstance<c10::complex<c10::Half> >()'
ocrpro.a(paper_ocr.cpp.o): In function `caffe2::TypeMeta caffe2::TypeMeta::Make<c10::complex<float> >()':
/Users/peter/paper/OCRRoot/pytorch_headers/c10/util/typeid.h:439: undefined reference to `caffe2::detail::TypeMetaData const* caffe2::TypeMeta::_typeMetaDataInstance<c10::complex<float> >()'
ocrpro.a(paper_ocr.cpp.o): In function `caffe2::TypeMeta caffe2::TypeMeta::Make<c10::complex<double> >()':
/Users/peter/paper/OCRRoot/pytorch_headers/c10/util/typeid.h:439: undefined reference to `caffe2::detail::TypeMetaData const* caffe2::TypeMeta::_typeMetaDataInstance<c10::complex<double> >()'
ocrpro.a(paper_ocr.cpp.o): In function `caffe2::TypeMeta caffe2::TypeMeta::Make<bool>()':
/Users/peter/paper/OCRRoot/pytorch_headers/c10/util/typeid.h:439: undefined reference to `caffe2::detail::TypeMetaData const* caffe2::TypeMeta::_typeMetaDataInstance<bool>()'
ocrpro.a(paper_ocr.cpp.o): In function `caffe2::TypeMeta caffe2::TypeMeta::Make<c10::qint8>()':
/Users/peter/paper/OCRRoot/pytorch_headers/c10/util/typeid.h:439: undefined reference to `caffe2::detail::TypeMetaData const* caffe2::TypeMeta::_typeMetaDataInstance<c10::qint8>()'
ocrpro.a(paper_ocr.cpp.o): In function `caffe2::TypeMeta caffe2::TypeMeta::Make<c10::quint8>()':
/Users/peter/paper/OCRRoot/pytorch_headers/c10/util/typeid.h:439: undefined reference to `caffe2::detail::TypeMetaData const* caffe2::TypeMeta::_typeMetaDataInstance<c10::quint8>()'
ocrpro.a(paper_ocr.cpp.o): In function `caffe2::TypeMeta caffe2::TypeMeta::Make<c10::qint32>()':
/Users/peter/paper/OCRRoot/pytorch_headers/c10/util/typeid.h:439: undefined reference to `caffe2::detail::TypeMetaData const* caffe2::TypeMeta::_typeMetaDataInstance<c10::qint32>()'
ocrpro.a(paper_ocr.cpp.o): In function `caffe2::TypeMeta caffe2::TypeMeta::Make<c10::BFloat16>()':
/Users/peter/paper/OCRRoot/pytorch_headers/c10/util/typeid.h:439: undefined reference to `caffe2::detail::TypeMetaData const* caffe2::TypeMeta::_typeMetaDataInstance<c10::BFloat16>()'
ocrpro.a(paper_ocr.cpp.o): In function `TypeMeta':
/Users/peter/paper/OCRRoot/pytorch_headers/c10/util/typeid.h:457: undefined reference to `caffe2::detail::TypeMetaData const* caffe2::TypeMeta::_typeMetaDataInstance<caffe2::detail::_Uninitialized>()'
ocrpro.a(paper_ocr.cpp.o): In function `c10::scalarTypeToTypeMeta(c10::ScalarType)':
/Users/peter/paper/OCRRoot/pytorch_headers/c10/core/ScalarType.h:159: undefined reference to `c10::Error::Error(c10::SourceLocation, std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> >)'
ocrpro.a(paper_ocr.cpp.o): In function `torch::jit::Object::get_method(std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> > const&) const':
/Users/peter/paper/OCRRoot/pytorch_headers/torch/csrc/jit/api/object.h:88: undefined reference to `torch::jit::Object::find_method(std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> > const&) const'
/Users/peter/paper/OCRRoot/pytorch_headers/torch/csrc/jit/api/object.h:91: undefined reference to `c10::Error::Error(c10::SourceLocation, std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> >)'
ocrpro.a(paper_ocr.cpp.o):(.data.rel.ro._ZTIN5torch8autograd12AutogradMetaE[_ZTIN5torch8autograd12AutogradMetaE]+0x10): undefined reference to `typeinfo for c10::AutogradMetaInterface'
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
ninja: build stopped: subcommand failed.

My enviroment is as following:
OS: MacOS 10.15.7
python: python3.8
gradle:5.6.4
ndk:android-21