Hi,
Below is my C++ code
#include <torch/torch.h>
#include <torch/script.h> // One-stop header.
#include
#include
struct ID : torch::nn::Module {};
using namespace std;
int main()
{
auto test = std::make_shared();
//torch::load(spkr_id,“net.pt”);
torch::save(test,“net.pt”);
}
I’m getting Linkage error As I’m running on the Android Platform with cross-compiled PyTorch libraries
rm: cannot remove ‘pytorch_app’: No such file or directory
– Check for working CXX compiler: /home/suresh/ANdroid_NEW_NDK/android-ndk-r21/toolchains/llvm/prebuilt/linux-x86_64/bin/clang++
– Check for working CXX compiler: /home/suresh/ANdroid_NEW_NDK/android-ndk-r21/toolchains/llvm/prebuilt/linux-x86_64/bin/clang++ – works
– Detecting CXX compiler ABI info
– Detecting CXX compiler ABI info - done
– Detecting CXX compile features
– Detecting CXX compile features - done
– Configuring done
– Generating done
– Build files have been written to: /home/suresh/spkrid_ali/spkrid_jio/testsrc/android/build
Scanning dependencies of target pytorch_app
[ 25%] Building CXX object CMakeFiles/pytorch_app.dir/src/mian.cpp.o
[ 50%] Building CXX object CMakeFiles/pytorch_app.dir/src/test.cpp.o
[ 75%] Building CXX object CMakeFiles/pytorch_app.dir/src/test_nn.cpp.o
[100%] Linking CXX executable pytorch_app
/home/suresh/pytorch/torch/csrc/api/src/serialize/output-archive.cpp:39: error: undefined reference to ‘torch::jit::ExportModule(torch::jit::script::Module const&, std::__ndk1::basic_string<char, std::__ndk1::char_traits, std::__ndk1::allocator > const&, std::__ndk1::unordered_map<std::__ndk1::basic_string<char, std::__ndk1::char_traits, std::__ndk1::allocator >, std::__ndk1::basic_string<char, std::__ndk1::char_traits, std::__ndk1::allocator >, std::__ndk1::hash<std::__ndk1::basic_string<char, std::__ndk1::char_traits, std::__ndk1::allocator > >, std::__ndk1::equal_to<std::__ndk1::basic_string<char, std::__ndk1::char_traits, std::__ndk1::allocator > >, std::__ndk1::allocator<std::__ndk1::pair<std::__ndk1::basic_string<char, std::__ndk1::char_traits, std::__ndk1::allocator > const, std::__ndk1::basic_string<char, std::__ndk1::char_traits, std::__ndk1::allocator > > > > const&, bool)’
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
CMakeFiles/pytorch_app.dir/build.make:157: recipe for target ‘pytorch_app’ failed
make[2]: *** [pytorch_app] Error 1
CMakeFiles/Makefile2:67: recipe for target ‘CMakeFiles/pytorch_app.dir/all’ failed
make[1]: *** [CMakeFiles/pytorch_app.dir/all] Error 2
Makefile:83: recipe for target ‘all’ failed
make: *** [all] Error 2