Hello,
I am just starting out with libtorch and seem to have run into a rather serious linker issue. Previously, I was able to at least build other projects with torch (that others had created), but now that I’ve tried to create my own simple file, nothing seems to be building anymore.
I have manually installed the latest MacOS build in my root directory:
/Users/jlenz/libtorch/share/cmake/Torch
I am using CLion and have the following CmakeLists.txt:
cmake_minimum_required(VERSION 3.23)
project(midi_plugin)
set(CMAKE_CXX_STANDARD 17)
add_executable(midi_plugin main.cpp)
set(CMAKE_PREFIX_PATH "~/libtorch/share/cmake")
find_package(Torch REQUIRED)
target_link_libraries(midi_plugin "${TORCH_LIBRARIES}")
One thing that is noticeable, although the cmake ‘succesfully’ builds, it displays this in the process:
-- MKL_ARCH: intel64
-- MKL_ROOT /Users/jlenz/opt/miniconda3
-- MKL_LINK: dynamic
-- MKL_INTERFACE_FULL: intel_ilp64
-- MKL_THREADING: intel_thread
-- MKL_MPI: mpich
Once I try to build the project (which is just ‘hello world’ with torch included) I get the following error:
FAILED: midi_plugin
: && /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ -g -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.1.sdk -mmacosx-version-min=12.5 -Wl,-search_paths_first -Wl,-headerpad_max_install_names CMakeFiles/midi_plugin.dir/main.cpp.o -o midi_plugin -Wl,-rpath,/Users/jlenz/libtorch/lib /Users/jlenz/libtorch/lib/libc10.dylib /Users/jlenz/libtorch/lib/libkineto.a /Users/jlenz/libtorch/lib/libtorch.dylib /Users/jlenz/libtorch/lib/libtorch_cpu.dylib /Users/jlenz/libtorch/lib/libc10.dylib -lmkl_intel_ilp64 -lmkl_core -lmkl_intel_thread && :
ld: library not found for -lmkl_intel_ilp64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Would anyone know how to solve this? I have tried addressing it with a colleague who has used libtorch quite a bit and he can’t identify the issue either. Many thanks in advance.