Getting LibTorch to work

Sklipnoty: <p>I was following the guide on <code>https://pytorch.org/cppdocs/installing.html</code></p>
<p>When running the make command I get the following errors;</p>
<pre><code class="lang-auto">make -j4
[ 50%] Linking CXX executable example-app
ld: warning: ignoring file /Users/axl/Documents/pytorch/libtorch/lib/libtorch.so, file was built for unsupported file format ( 0x7F 0x45 0x4C 0x46 0x02 0x01 0x01 0x03 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 ) which is not the architecture being linked (x86_64): /Users/axl/Documents/pytorch/libtorch/lib/libtorch.so
ld: warning: ignoring file /Users/axl/Documents/pytorch/libtorch/lib/libcaffe2.so, file was built for unsupported file format ( 0x7F 0x45 0x4C 0x46 0x02 0x01 0x01 0x03 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 ) which is not the architecture being linked (x86_64): /Users/axl/Documents/pytorch/libtorch/lib/libcaffe2.so
ld: warning: ignoring file /Users/axl/Documents/pytorch/libtorch/lib/libc10.so, file was built for unsupported file format ( 0x7F 0x45 0x4C 0x46 0x02 0x01 0x01 0x03 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 ) which is not the architecture being linked (x86_64): /Users/axl/Documents/pytorch/libtorch/lib/libc10.so
Undefined symbols for architecture x86_64:
  "at::UndefinedTensorImpl::_singleton", referenced from:
      at::UndefinedTensorImpl::singleton() in main.cpp.o
  "at::print(std::__1::basic_ostream&lt;char, std::__1::char_traits&lt;char&gt; &gt;&amp;, at::Tensor const&amp;, long long)", referenced from:
      at::operator&lt;&lt;(std::__1::basic_ostream&lt;char, std::__1::char_traits&lt;char&gt; &gt;&amp;, at::Tensor const&amp;) in main.cpp.o
  "at::native::rand(c10::ArrayRef&lt;long long&gt;, c10::TensorOptions const&amp;)", referenced from:
      at::rand(c10::ArrayRef&lt;long long&gt;, c10::TensorOptions const&amp;) in main.cpp.o
  "c10::impl::device_guard_impl_registry", referenced from:
      c10::impl::getDeviceGuardImpl(c10::DeviceType) in main.cpp.o
  "c10::Error::Error(c10::SourceLocation, std::__1::basic_string&lt;char, std::__1::char_traits&lt;char&gt;, std::__1::allocator&lt;char&gt; &gt; const&amp;)", referenced from:
      torch::autograd::make_variable(at::Tensor, bool) in main.cpp.o
      torch::jit::Block::appendNode(torch::jit::Node*) in main.cpp.o
      torch::jit::Node::inBlockList() const in main.cpp.o
      c10::impl::getDeviceGuardImpl(c10::DeviceType) in main.cpp.o
      c10::intrusive_ptr&lt;at::TensorImpl, at::UndefinedTensorImpl&gt;::retain_() in main.cpp.o
  "c10::Device::validate()", referenced from:
      c10::Device::Device(c10::DeviceType, short) in main.cpp.o
  "c10::Symbol::fromQualString(std::__1::basic_string&lt;char, std::__1::char_traits&lt;char&gt;, std::__1::allocator&lt;char&gt; &gt; const&amp;)", referenced from:
      torch::rand(c10::ArrayRef&lt;long long&gt;, c10::TensorOptions const&amp;) in main.cpp.o
  "c10::operator&lt;&lt;(std::__1::basic_ostream&lt;char, std::__1::char_traits&lt;char&gt; &gt;&amp;, c10::DeviceType)", referenced from:
      std::__1::basic_ostream&lt;char, std::__1::char_traits&lt;char&gt; &gt;&amp; c10::detail::_str&lt;c10::DeviceType&gt;(std::__1::basic_ostream&lt;char, std::__1::char_traits&lt;char&gt; &gt;&amp;, c10::DeviceType const&amp;) in main.cpp.o
  "torch::jit::Node::insertBefore(torch::jit::Node*)", referenced from:
      torch::jit::Block::appendNode(torch::jit::Node*) in main.cpp.o
  "torch::jit::Graph::create(c10::Symbol, unsigned long)", referenced from:
      torch::rand(c10::ArrayRef&lt;long long&gt;, c10::TensorOptions const&amp;) in main.cpp.o
  "torch::jit::tracer::getTracingState()", referenced from:
      torch::rand(c10::ArrayRef&lt;long long&gt;, c10::TensorOptions const&amp;) in main.cpp.o
      torch::jit::tracer::isTracing() in main.cpp.o
  "torch::jit::tracer::setTracingState(std::__1::shared_ptr&lt;torch::jit::tracer::TracingState&gt;)", referenced from:
      torch::rand(c10::ArrayRef&lt;long long&gt;, c10::TensorOptions const&amp;) in main.cpp.o
  "torch::jit::tracer::recordSourceLocation(torch::jit::Node*)", referenced from:
      torch::rand(c10::ArrayRef&lt;long long&gt;, c10::TensorOptions const&amp;) in main.cpp.o
  "torch::jit::tracer::addInputs(torch::jit::Node*, char const*, c10::ArrayRef&lt;long long&gt;)", referenced from:
      torch::rand(c10::ArrayRef&lt;long long&gt;, c10::TensorOptions const&amp;) in main.cpp.o
  "torch::jit::tracer::addInputs(torch::jit::Node*, char const*, c10::TensorOptions const&amp;)", referenced from:
      torch::rand(c10::ArrayRef&lt;long long&gt;, c10::TensorOptions const&amp;) in main.cpp.o
  "torch::jit::tracer::addOutput(torch::jit::Node*, at::Tensor const&amp;)", referenced from:
      torch::rand(c10::ArrayRef&lt;long long&gt;, c10::TensorOptions const&amp;) in main.cpp.o
  "torch::autograd::Variable::Impl::Impl(at::Tensor, bool, torch::autograd::Edge)", referenced from:
      c10::intrusive_ptr&lt;torch::autograd::Variable::Impl, c10::detail::intrusive_target_default_null_type&lt;torch::autograd::Variable::Impl&gt; &gt; c10::intrusive_ptr&lt;torch::autograd::Variable::Impl, c10::detail::intrusive_target_default_null_type&lt;torch::autograd::Variable::Impl&gt; &gt;::make&lt;at::Tensor&amp;, bool&amp;&gt;(at::Tensor&amp;&amp;&amp;, bool&amp;&amp;&amp;) in main.cpp.o
  "caffe2::detail::_typeMetaDataInstance_preallocated_6", referenced from:
      caffe2::detail::TypeMetaData const* caffe2::TypeMeta::_typeMetaDataInstance&lt;float&gt;() in main.cpp.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [example-app] Error 1
make[1]: *** [CMakeFiles/example-app.dir/all] Error 2
make: *** [all] Error 2
</code></pre>

Raul-Cardona: <p>Did you ever find a solution? Getting the exact same thing when running make command</p>

Raul-Cardona: <p>I know it’s been a while since you posted this lol</p>