# Loading a x86 shared library on a macBook M2

**URL:** https://discourse.julialang.org/t/loading-a-x86-shared-library-on-a-macbook-m2/96624
**Category:** New to Julia
**Created:** [March 26, 2023, 9:50am UTC](https://discourse.julialang.org/t/loading-a-x86-shared-library-on-a-macbook-m2/96624 "2023-03-26T09:50:56Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![mmv](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mmv/32/26323_2.png) [@mmv](https://discourse.julialang.org/u/mmv)
#### Post date: [March 26, 2023, 9:50am UTC](https://discourse.julialang.org/t/loading-a-x86-shared-library-on-a-macbook-m2/96624/1 "2023-03-26T09:50:56Z")

</div>

Hi!

I’m moving a Julia project from an old MacBook Pro (2017) with an Intel Core i7 chip to a brand new one (2023) with the M2 Max.

My project requires a C shared library which is not yet available on this new platform, so I copied the x86 version to the standard location on the M2 computer.

When I call a function that uses that library, I get the following error message complaining about “incompatible architecture”:

```julia
julia> include(JMtk15_test * "src/jMtkVersion_tst.jl")
jMtkVersion_tst

julia> version = jMtkVersion_tst();
ERROR: could not load library "/Applications/Mtk-1.5.0/lib/libMisrToolkit.so.1.5.0"
dlopen(/Applications/Mtk-1.5.0/lib/libMisrToolkit.so.1.5.0, 0x0001): tried: '/Applications/Mtk-1.5.0/lib/libMisrToolkit.so.1.5.0' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64')), '/System/Volumes/Preboot/Cryptexes/OS/Applications/Mtk-1.5.0/lib/libMisrToolkit.so.1.5.0' (no such file), '/Applications/Mtk-1.5.0/lib/libMisrToolkit.so.1.5.0' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64'))
Stacktrace:
 [1] jMtkVersion
   @ ~/Projects/MISR/MISR_Toolkit/JMtk15/src/jMtkVersion.jl:26 [inlined]
 [2] jMtkVersion_tst()
   @ Main ~/Projects/MISR/MISR_Toolkit/JMtk15/test/src/jMtkVersion_tst.jl:39
 [3] top-level scope
   @ REPL[6]:1

```

Since Rosetta has been previously installed, I was expecting this to work. This library is correctly found, but cannot be loaded. What do I need to do to enable Julia on the M2 chip to recognize and use that shared library compiled for the x86 chip? Thanks for your help.

---

<div class="post-metadata">

### Author: ![LaurentPlagne](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/laurentplagne/32/10103_2.png) [@LaurentPlagne](https://discourse.julialang.org/u/LaurentPlagne)
#### Post date: [March 26, 2023, 11:48am UTC](https://discourse.julialang.org/t/loading-a-x86-shared-library-on-a-macbook-m2/96624/2 "2023-03-26T11:48:41Z")

</div>

Not sure but I think that you need to use x86 version of Julia via Rosetta.

---

<div class="post-metadata">

### Author: ![giordano](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/giordano/32/2166_2.png) [@giordano](https://discourse.julialang.org/u/giordano)
#### Post date: [March 26, 2023, 5:55pm UTC](https://discourse.julialang.org/t/loading-a-x86-shared-library-on-a-macbook-m2/96624/3 "2023-03-26T17:55:48Z")

</div>

Yes, you can’t mix libraries for different architectures within the same process. Rosetta works on the entire process, so you need an x86\_64 Julia run under Rosetta to load an x86\_64 library.

---

<div class="post-metadata">

### Author: ![mmv](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mmv/32/26323_2.png) [@mmv](https://discourse.julialang.org/u/mmv)
#### Post date: [March 26, 2023, 9:39pm UTC](https://discourse.julialang.org/t/loading-a-x86-shared-library-on-a-macbook-m2/96624/4 "2023-03-26T21:39:23Z")

</div>

Thanks to both of you for addressing this issue. Here are follow-up questions, then:

- How is this implemented? Do I need to install a new, separate ‘x86\_64’ version of Julia?

- If so, how can I prevent the ‘x86\_64’ version from replacing the working ‘arm64’ version, as I would like to use the native ‘arm64’ version whenever possible?

- How do I manage multiple instances of Julia on the same platform? In particular, how do I call either version specifically, depending on the use case?

Thanks for clarifying those points.

---

<div class="post-metadata">

### Author: ![giordano](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/giordano/32/2166_2.png) [@giordano](https://discourse.julialang.org/u/giordano)
#### Post date: [March 26, 2023, 10:16pm UTC](https://discourse.julialang.org/t/loading-a-x86-shared-library-on-a-macbook-m2/96624/5 "2023-03-26T22:16:52Z")

</div>

> **[GitHub - JuliaLang/juliaup: Julia installer and version multiplexer](https://github.com/JuliaLang/juliaup)**
>
> Julia installer and version multiplexer. Contribute to JuliaLang/juliaup development by creating an account on GitHub.

---

<div class="post-metadata">

### Author: ![mmv](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mmv/32/26323_2.png) [@mmv](https://discourse.julialang.org/u/mmv)
#### Post date: [March 26, 2023, 10:44pm UTC](https://discourse.julialang.org/t/loading-a-x86-shared-library-on-a-macbook-m2/96624/6 "2023-03-26T22:44:39Z")

</div>

Great! Thanks a lot @giordano.
