# Issue with build MKL on Windows 10

**URL:** <https://discourse.julialang.org/t/issue-with-build-mkl-on-windows-10/38502>\
**Category:** General Usage\
**Tags:** mkl\
**Created:** [April 30, 2020, 7:04pm UTC](https://discourse.julialang.org/t/issue-with-build-mkl-on-windows-10/38502 "2020-04-30T19:04:03Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Andrei\_Bobrov](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/andrei_bobrov/32/8438_2.png) [@Andrei\_Bobrov](https://discourse.julialang.org/u/Andrei_Bobrov)\
**Post date:** [April 30, 2020, 7:04pm UTC](https://discourse.julialang.org/t/issue-with-build-mkl-on-windows-10/38502/1 "2020-04-30T19:04:03Z")

</div>

I am have issue with build MKL after install MKL.jl (antivirus (Kaspersky) disabled).

```julia
(@v1.4) pkg> build MKL
   Building MKL → `J:\Julia_depot\packages\MKL\1edTo\deps\build.log`
┌ Error: Error building `MKL`:
│ Generating precompile statements... 4980 generated in 125.676000 seconds (overhead 91.511079 seconds)
│ [ Info: Splicing in code to load MKL in J:\Julia-1.4.1\bin\..\share\julia\base\sysimg.jl
│ [ Info: getting precompile script from: https://raw.githubusercontent.com/JuliaLang/julia/release-1.4/contrib/generate_precompile.jl
│ [ Info: PackageCompiler: creating base system image (incremental=false)...
│ [ Info: PackageCompiler: creating system image object file, this might take a while...
│ ERROR: LoadError: IOError: unlink: permission denied (EACCES)
│ Stacktrace:
│ [1] uv_error at .\libuv.jl:97 [inlined]
│ [2] unlink(::String) at .\file.jl:888
│ [3] rm(::String; force::Bool, recursive::Bool) at .\file.jl:268
│ [4] rename(::String, ::String) at .\file.jl:899
│ [5] #mv#13 at .\file.jl:393 [inlined]
│ [6] mv at .\file.jl:392 [inlined]
│ [7] move_default_sysimage_if_windows() at J:\Julia_depot\packages\PackageCompiler\xtztx\src\PackageCompiler.jl:83
│ [8] create_sysimage(::Array{Symbol,1}; sysimage_path::Nothing, project::String, precompile_execution_file::Array{String,1}, precompile_statements_file::Array{String,1}, incremental::Bool, filter_stdlibs::Bool, replace_default::Bool, cpu_target::String, script::String, base_sysimage::Nothing, isapp::Bool) at J:\Julia_depot\packages\PackageCompiler\xtztx\src\PackageCompiler.jl:439
│ [9] top-level scope at J:\Julia_depot\packages\MKL\1edTo\src\install.jl:107
│ [10] eval at .\boot.jl:331 [inlined]
│ [11] change_blas_library(::String) at J:\Julia_depot\packages\MKL\1edTo\src\install.jl:105
│ [12] enable_mkl_startup() at J:\Julia_depot\packages\MKL\1edTo\src\install.jl:82
│ [13] top-level scope at J:\Julia_depot\packages\MKL\1edTo\deps\build.jl:5
│ [14] include(::String) at .\client.jl:439
│ [15] top-level scope at none:5
│ in expression starting at J:\Julia_depot\packages\MKL\1edTo\deps\build.jl:5
└ @ Pkg.Operations D:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.4\Pkg\src\Operations.jl:892

julia> versioninfo()
Julia Version 1.4.1
Commit 381693d3df* (2020-04-14 17:20 UTC)
Platform Info:
  OS: Windows (x86_64-w64-mingw32)
  CPU: Intel(R) Core(TM) i7-3770K CPU @ 3.50GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-8.0.1 (ORCJIT, ivybridge)
Environment:
  JULIA_DEPOT_PATH = J:\Julia_depot

```

---

<div class="post-metadata">

**Author:** ![blackeneth](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/blackeneth/32/10353_2.png) [@blackeneth](https://discourse.julialang.org/u/blackeneth)\
**Post date:** [May 2, 2020, 6:17am UTC](https://discourse.julialang.org/t/issue-with-build-mkl-on-windows-10/38502/2 "2020-05-02T06:17:12Z")

</div>

Looks like a permission error.  
An easy thing to try is run Julia as Administrator.

---

<div class="post-metadata">

**Author:** ![RoyiAvital](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/royiavital/32/571_2.png) [@RoyiAvital](https://discourse.julialang.org/u/RoyiAvital)\
**Post date:** [May 2, 2020, 7:43am UTC](https://discourse.julialang.org/t/issue-with-build-mkl-on-windows-10/38502/3 "2020-05-02T07:43:56Z")

</div>

> [@blackeneth](#):
>
> An easy thing to try is run Julia as Administrator.

I don’t think it is a recommended solution.  
Why, in order to install package, one would need elevated privileges?  
It seems @Andrei_Bobrov doesn’t even try to install it into a system path. Why would he need Admin rights?

---

<div class="post-metadata">

**Author:** ![kristoffer.carlsson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kristoffer.carlsson/32/22_2.png) [@kristoffer.carlsson](https://discourse.julialang.org/u/kristoffer.carlsson)\
**Post date:** [May 2, 2020, 7:46am UTC](https://discourse.julialang.org/t/issue-with-build-mkl-on-windows-10/38502/4 "2020-05-02T07:46:50Z")

</div>

The issue is that the default sysimage is supposed to be replaced but on windows moving/deleting files that are in use is pretty problematic. The code right now moves the existing sysimage and then adds the new one in its place which has worked for me but apparently it doesn’t work all the time.

---

<div class="post-metadata">

**Author:** ![Andrei\_Bobrov](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/andrei_bobrov/32/8438_2.png) [@Andrei\_Bobrov](https://discourse.julialang.org/u/Andrei_Bobrov)\
**Post date:** [May 2, 2020, 8:20am UTC](https://discourse.julialang.org/t/issue-with-build-mkl-on-windows-10/38502/5 "2020-05-02T08:20:14Z")

</div>

@RoyiAvital is right - the same problem.

---

<div class="post-metadata">

**Author:** ![RoyiAvital](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/royiavital/32/571_2.png) [@RoyiAvital](https://discourse.julialang.org/u/RoyiAvital)\
**Post date:** [May 2, 2020, 8:35am UTC](https://discourse.julialang.org/t/issue-with-build-mkl-on-windows-10/38502/6 "2020-05-02T08:35:35Z")

</div>

> [@kristoffer.carlsson](#):
>
> The issue is that the default sysimage is supposed to be replaced but on windows moving/deleting files that are in use is pretty problematic. The code right now moves the existing sysimage and then adds the new one in its place which has worked for me but apparently it doesn’t work all the time.

@kristoffer.carlsson, Maybe the solution is like how Operating Systems updates work.  
They schedule the file replacement to the next restart.  
So maybe you could insert the operations to replace System Image to the ext loading of Julia?  
Does Julia have something, which is user configurable, to run before it loads Sys Image?
