Building julia with Intel MKL: libimf not found

I’m trying to build julia (tag v0.6.2) from source. I have already installed intel MKL, IPP, TBB and MPI in my system (elementaryOS 0.4.1, based on Ubuntu 16.04) and setup the compiler variable using the script in /opt/intel/bin/
I modified as below:

## Settings for various Intel tools
# Set to 1 to use MKL
# Set to 1 to use MKL FFT
# Set to 1 to use Intel LIBM

When I try to make, I’m getting this error:

fatal: error thrown and no exception handler available.
ErrorException("error compiling ndigits: error compiling ndigits0z: could not load library "libimf" cannot open shared object file: No such file or directory")
rec_backtrace at /opt/julialang/src/julia/src/stackwalk.c:84
record_backtrace at /opt/julialang/src/julia/src/task.c:245
jl_throw at /opt/julialang/src/julia/src/task.c:564
jl_rethrow_with_add at /opt/julialang/src/julia/src/codegen.cpp:912
jl_compile_linfo at /opt/julialang/src/julia/src/codegen.cpp:1270
jl_compile_hint at /opt/julialang/src/julia/src/gf.c:1724
jl_compile_specializations at /opt/julialang/src/julia/src/precompile.c:344 [inlined]
jl_precompile at /opt/julialang/src/julia/src/precompile.c:353 [inlined]
jl_write_compiler_output at /opt/julialang/src/julia/src/precompile.c:31
jl_atexit_hook at /opt/julialang/src/julia/src/init.c:238
main at /opt/julialang/src/julia/ui/repl.c:265
__libc_start_main at /build/glibc-Cl5G7W/glibc-2.23/csu/../csu/libc-start.c:291
unknown function (ip: 0x4016b8)
*** This error is usually fixed by running `make clean`. If the error persists, try `make cleanall`. ***
Makefile:233: recipe for target '/opt/julialang/src/julia/usr/lib/julia/sys.o' failed
make[1]: *** [/opt/julialang/src/julia/usr/lib/julia/sys.o] Error 1
Makefile:109: recipe for target 'julia-sysimg-release' failed
make: *** [julia-sysimg-release] Error 2

What could be the problem?

In Linux I think you need to install the Intel runtime to use the Intel libm. See this post by @SebastianM-C:

I installed intel psxe runtime using this method:

But still I’m getting the same error :frowning:

Did you source the intel compilervars in the same terminal?
I added the line to my .bashrc, because even after Julia is built, it will error if I didn’t source compilervars. (Eg, crash on matrix multiplication.)

Yes… I made it sure.
Otherwise, at the start itself, it will complain about missing MKL library. So I guess the compilervars are set properly.