# Error in bulid MPI

**URL:** <https://discourse.julialang.org/t/error-in-bulid-mpi/43948>\
**Category:** General Usage\
**Tags:** mpi\
**Created:** [July 30, 2020, 4:15am UTC](https://discourse.julialang.org/t/error-in-bulid-mpi/43948 "2020-07-30T04:15:25Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ke\_Gao](https://avatars.discourse-cdn.com/v4/letter/k/71e660/32.png) [@Ke\_Gao](https://discourse.julialang.org/u/Ke_Gao)\
**Post date:** [July 30, 2020, 4:15am UTC](https://discourse.julialang.org/t/error-in-bulid-mpi/43948/1 "2020-07-30T04:15:25Z")

</div>

Hi,

I had an error when I built MPI on my MacBook:

```julia
(@v1.4) pkg> build MPI
   Building MPI → `~/.julia/packages/MPI/k7f4E/deps/build.log`
┌ Error: Error building `MPI`: 
│ [ Info: using system MPI
│ ERROR: LoadError: libmpi could not be found
│ Stacktrace:
│ [1] error(::String) at ./error.jl:33
│ [2] top-level scope at /Users/ke/.julia/packages/MPI/k7f4E/deps/build.jl:75
│ [3] include(::String) at ./client.jl:439
│ [4] top-level scope at none:5
│ in expression starting at /Users/ke/.julia/packages/MPI/k7f4E/deps/build.jl:63
└ @ Pkg.Operations /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.4/Pkg/src/Operations.jl:899

```

I have installed open\_mpi via Homebrew before I built MPI in Julia.

Could anyone help me to fix it? Thank you!

---

<div class="post-metadata">

**Author:** ![jipolanco](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jipolanco/32/12129_2.png) [@jipolanco](https://discourse.julialang.org/u/jipolanco)\
**Post date:** [July 30, 2020, 5:40am UTC](https://discourse.julialang.org/t/error-in-bulid-mpi/43948/2 "2020-07-30T05:40:36Z")

</div>

Hi, it seems like MPI.jl could not find your installation of OpenMPI.

If you know the path to that installation, you can try setting the `JULIA_MPI_PATH` environment variable before building again, as detailed in [the MPI.jl docs](https://juliaparallel.github.io/MPI.jl/stable/configuration/#environment_variables-1).

---

<div class="post-metadata">

**Author:** ![Ke\_Gao](https://avatars.discourse-cdn.com/v4/letter/k/71e660/32.png) [@Ke\_Gao](https://discourse.julialang.org/u/Ke_Gao)\
**Post date:** [July 30, 2020, 6:51am UTC](https://discourse.julialang.org/t/error-in-bulid-mpi/43948/3 "2020-07-30T06:51:12Z")

</div>

Yeah, you are right!  
I add a line to `.bash_profile`:

```julia
export JULIA_MPI_PATH=/usr/local/Cellar/open-mpi/4.0.4_1

```

and build MPI again, then it worked.

Thank you!

---

<div class="post-metadata">

**Author:** ![Lightup1](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lightup1/32/35410_2.png) [@Lightup1](https://discourse.julialang.org/u/Lightup1)\
**Post date:** [June 22, 2022, 7:30am UTC](https://discourse.julialang.org/t/error-in-bulid-mpi/43948/4 "2022-06-22T07:30:45Z")

</div>

I have the same error and it is still not working even if I specify `JULIA_MPI_PATH` and `JULIA_MPI_LIBRARY`.  
Here is the lib file

```julia
$ /usr/local/mpi3-dynamic/lib 
$ls
libfmpich.so libmpichcxx.so libmpich.so libmpicxx.la libmpicxx.so.12 libmpifort.a libmpifort.so libmpifort.so.12.0.4 libmpi.so libmpi.so.12.0.4 libopa.so
libmpi.a libmpichf90.so libmpicxx.a libmpicxx.so libmpicxx.so.12.0.4 libmpifort.la libmpifort.so.12 libmpi.la libmpi.so.12 libmpl.so pkgconfig

```

error message:

```julia
julia -t1 --project -e 'ENV["JULIA_MPI_PATH"]="/usr/local/mpi3-dynamic"; using Pkg; Pkg.build("MPI"; verbose=true)'
    Building MPI → `~/.julia/scratchspaces/44cfe95a-1eb2-52ea-b672-e2afdf69b78f/d56a80d8cf8b9dc3050116346b3d83432b1912c0/build.log`
[Info: using system MPI] 0/1
ERROR: LoadError: libmpi could not be found
Stacktrace:
 [1] error(s::String)
   @ Base ./error.jl:33
 [2] top-level scope
   @ ~/.julia/packages/MPI/08SPr/deps/build.jl:76
 [3] include(fname::String)
   @ Base.MainInclude ./client.jl:451
 [4] top-level scope
   @ none:5
in expression starting at HOME/.julia/packages/MPI/08SPr/deps/build.jl:64
ERROR: Error building `MPI`: 

Stacktrace:
  [1] pkgerror(msg::String)
    @ Pkg.Types ~/.julia-1.7.3/share/julia/stdlib/v1.7/Pkg/src/Types.jl:68
  [2] (::Pkg.Operations.var"#62#67"{Bool, Pkg.Types.Context, String, Pkg.Types.PackageSpec})()
    @ Pkg.Operations ~/.julia-1.7.3/share/julia/stdlib/v1.7/Pkg/src/Operations.jl:962
  [3] withenv(::Pkg.Operations.var"#62#67"{Bool, Pkg.Types.Context, String, Pkg.Types.PackageSpec}, ::Pair{String, String}, ::Vararg{Pair{String}})
    @ Base ./env.jl:172
  [4] (::Pkg.Operations.var"#99#103"{String, Bool, Bool, Bool, Pkg.Operations.var"#62#67"{Bool, Pkg.Types.Context, String, Pkg.Types.PackageSpec}, Pkg.Types.PackageSpec})()
    @ Pkg.Operations ~/.julia-1.7.3/share/julia/stdlib/v1.7/Pkg/src/Operations.jl:1506
  [5] with_temp_env(fn::Pkg.Operations.var"#99#103"{String, Bool, Bool, Bool, Pkg.Operations.var"#62#67"{Bool, Pkg.Types.Context, String, Pkg.Types.PackageSpec}, Pkg.Types.PackageSpec}, temp_env::String)
    @ Pkg.Operations ~/.julia-1.7.3/share/julia/stdlib/v1.7/Pkg/src/Operations.jl:1390
  [6] (::Pkg.Operations.var"#98#102"{Bool, Bool, Bool, Pkg.Operations.var"#62#67"{Bool, Pkg.Types.Context, String, Pkg.Types.PackageSpec}, Pkg.Types.Context, Pkg.Types.PackageSpec, String, Pkg.Types.Project, String})(tmp::String)
    @ Pkg.Operations ~/.julia-1.7.3/share/julia/stdlib/v1.7/Pkg/src/Operations.jl:1469
  [7] mktempdir(fn::Pkg.Operations.var"#98#102"{Bool, Bool, Bool, Pkg.Operations.var"#62#67"{Bool, Pkg.Types.Context, String, Pkg.Types.PackageSpec}, Pkg.Types.Context, Pkg.Types.PackageSpec, String, Pkg.Types.Project, String}, parent::String; prefix::String)
    @ Base.Filesystem ./file.jl:750
  [8] mktempdir(fn::Function, parent::String) (repeats 2 times)
    @ Base.Filesystem ./file.jl:748
  [9] sandbox(fn::Function, ctx::Pkg.Types.Context, target::Pkg.Types.PackageSpec, target_path::String, sandbox_path::String, sandbox_project_override::Pkg.Types.Project; force_latest_compatible_version::Bool, allow_earlier_backwards_compatible_versions::Bool, allow_reresolve::Bool)
    @ Pkg.Operations ~/.julia-1.7.3/share/julia/stdlib/v1.7/Pkg/src/Operations.jl:1435
 [10] sandbox(fn::Function, ctx::Pkg.Types.Context, target::Pkg.Types.PackageSpec, target_path::String, sandbox_path::String, sandbox_project_override::Pkg.Types.Project)
    @ Pkg.Operations ~/.julia-1.7.3/share/julia/stdlib/v1.7/Pkg/src/Operations.jl:1432
 [11] build_versions(ctx::Pkg.Types.Context, uuids::Set{Base.UUID}; verbose::Bool)
    @ Pkg.Operations ~/.julia-1.7.3/share/julia/stdlib/v1.7/Pkg/src/Operations.jl:943
 [12] build(ctx::Pkg.Types.Context, uuids::Set{Base.UUID}, verbose::Bool)
    @ Pkg.Operations ~/.julia-1.7.3/share/julia/stdlib/v1.7/Pkg/src/Operations.jl:822
 [13] build(ctx::Pkg.Types.Context, pkgs::Vector{Pkg.Types.PackageSpec}; verbose::Bool, kwargs::Base.Pairs{Symbol, Base.TTY, Tuple{Symbol}, NamedTuple{(:io,), Tuple{Base.TTY}}})
    @ Pkg.API ~/.julia-1.7.3/share/julia/stdlib/v1.7/Pkg/src/API.jl:992
 [14] build(pkgs::Vector{Pkg.Types.PackageSpec}; io::Base.TTY, kwargs::Base.Pairs{Symbol, Bool, Tuple{Symbol}, NamedTuple{(:verbose,), Tuple{Bool}}})
    @ Pkg.API ~/.julia-1.7.3/share/julia/stdlib/v1.7/Pkg/src/API.jl:149
 [15] #build#99
    @ ~/.julia-1.7.3/share/julia/stdlib/v1.7/Pkg/src/API.jl:142 [inlined]
 [16] #build#98
    @ ~/.julia-1.7.3/share/julia/stdlib/v1.7/Pkg/src/API.jl:141 [inlined]
 [17] top-level scope
    @ none:1

```

---

<div class="post-metadata">

**Author:** ![christmas\_jones](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/christmas_jones/32/29540_2.png) [@christmas\_jones](https://discourse.julialang.org/u/christmas_jones)\
**Post date:** [July 20, 2022, 6:38pm UTC](https://discourse.julialang.org/t/error-in-bulid-mpi/43948/5 "2022-07-20T18:38:41Z")

</div>

Hi,  
This might help, I was having similar issues recently:

> [@Error building MPI---ERROR: LoadError: libmpi could not be found](https://discourse.julialang.org/t/error-building-mpi-error-loaderror-libmpi-could-not-be-found/65016/4):
>
> Thanks for this, this was bugging me for ages (on Mac M1, julia 1.8). I found I also had to set the library path for it to not throw the error about libmpi. For me, I had MPI installed via homebrew, and the following steps worked (in case anyone else had similar issues): export JULIA\_MPI\_PATH=/opt/homebrew/Cellar/open-mpi/4.1.4 export JULIA\_MPI\_LIBRARY=/opt/homebrew/Cellar/open-mpi/4.1.4/lib/libmpi julia -e 'ENV["JULIA\_MPI\_BINARY"]="system"; using Pkg; Pkg.build("MPI"; verbose=true)' This resu…

BTW, are your lib files there an alias or executable? On Mac you can do ‘show original’ for alias files (and I assume similar on linux). As far as I could tell, the JULIA\_MPI\_LIBRARY path should be to the executable (for me there is a libmpi.40.dylib executable file in the directory I linked).
