I’m compiling a library which links to pytorch and is then used to build an iOS app.
However when i build the project in XCode i get the following errors:
Undefined symbols for architecture x86_64:
"_cpuinfo_get_processors_count", referenced from:
caffe2::getDefaultNumThreads() in libtorch_cpu.a(ThreadPool.cc.o)
"_pthreadpool_get_threads_count", referenced from:
caffe2::PThreadPool::get_thread_count() const in libtorch_cpu.a(pthreadpool-cpp.cc.o)
"_pthreadpool_create", referenced from:
caffe2::PThreadPool::PThreadPool(unsigned long) in libtorch_cpu.a(pthreadpool-cpp.cc.o)
caffe2::PThreadPool::set_thread_count(unsigned long) in libtorch_cpu.a(pthreadpool-cpp.cc.o)
"_pthreadpool_destroy", referenced from:
caffe2::PThreadPool::PThreadPool(unsigned long) in libtorch_cpu.a(pthreadpool-cpp.cc.o)
"_pthreadpool_parallelize_1d", referenced from:
caffe2::PThreadPool::run(std::__1::function<void (unsigned long)> const&, unsigned long) in libtorch_cpu.a(pthreadpool-cpp.cc.o)
"_cpuinfo_initialize", referenced from:
caffe2::getDefaultNumThreads() in libtorch_cpu.a(ThreadPool.cc.o)
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Checking the libtorch_cpu.a
using nm
I found that _cpuinfo_initialize
and _cpuinfo_get_processors_count
are undefined.
To build my pytorch libraries I’ve set NO_API to OFF
as well as BUILD_MOBILE_AUTOGRAD to ON
in the root CMakeLists file of pytorch.
I then run IOS_PLATFORM=SIMULATOR BUILD_PYTORCH_MOBILE=1 BUILD_LITE_INTERPRETER=0 ./scripts/build_ios.sh
.
When building my library, I link to libtorch_cpu.a
and libc10.a
Any ideas ?