CLion error vs. building in terminal - intel MKL library


I am working on an audio application dynamically links to subdirectory with libtorch dlls. I use the following commands to build on terminal:

cmake .. -DCMAKE_BUILD_TYPE=Debug
cmake --build . --config Debug

When building/running this way, the programme compiles perfectly. However, when I try to build it through CLion (including its built-in CMake), I get the following notifications during cmake build process:

-- MKL_ARCH: None, set to ` intel64` by default
-- MKL_ROOT /Users/jlenz/opt/miniconda3
-- MKL_LINK: None, set to ` dynamic` by default
-- MKL_INTERFACE_FULL: None, set to ` intel_ilp64` by default
-- MKL_THREADING: None, set to ` intel_thread` by default
-- MKL_MPI: None, set to ` mpich` by default

and then when I try to build the programme:

ld: library not found for -lmkl_intel_ilp64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
ninja: build stopped: subcommand failed.

I’m fairly new to cmake, and cannot understand why building it in terminal works, but CLion doesn’t (I am using all default settings in my Clion cmake preferences). Any insight as to how I can ‘align’ these two, so that CLion is using the same, functional settings that are occuring when I build from terminal?


I suspect your shell is loading the Intel toolchain properly while CLion (probably launched from a system menu) does not. Does it work if you launch CLion from an otherwise-working shell?