# Compiling HashLink on macOS Apple Silicon

**URL:** https://community.haxe.org/t/compiling-hashlink-on-macos-apple-silicon/3150
**Category:** Haxe
**Tags:** haxe-hl
**Created:** [July 13, 2021, 8:53pm UTC](https://community.haxe.org/t/compiling-hashlink-on-macos-apple-silicon/3150 "2021-07-13T20:53:40Z")
**Posts on this page:** 12
**Page:** 1

<div class="post-metadata">

### Author: ![joshtynjala](https://community.haxe.org/user_avatar/community.haxe.org/joshtynjala/32/792_2.png) [@joshtynjala](https://community.haxe.org/u/joshtynjala)
#### Post date: [July 13, 2021, 8:53pm UTC](https://community.haxe.org/t/compiling-hashlink-on-macos-apple-silicon/3150/1 "2021-07-13T20:53:40Z")

</div>

The current instructions to [build HashLink](https://github.com/HaxeFoundation/hashlink) on macOS don’t work on new Apple Silicon CPUs. However, I think that I’ve figured out how build for x86\_64 on Apple Silicon.

First, install the Intel version of Homebrew using the following command:

```haxe
arch -x86_64 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

```

You can have both Apple Silicon and Intel versions of Homebrew installed at the same time because the Apple Silicon version uses _/opt/homebrew_ and the Intel version uses _/usr/local/_.

Once you get the right version of Homebrew, you need to run slightly different commands when building HashLink.

When the HashLink build instructions say to run `brew bundle`, you must run it with the Intel version (you might not need the `arch -x86_64` part of this command, but I used it to be safe)

```haxe
arch -x86_64 /usr/local/bin/brew bundle

```

Then, when running `make`, you must add `arch -x86_64` before it (the arch part definitely not optional on this command) to ensure that it compiles for Intel instead of Apple Silicon.

```haxe
arch -x86_64 make

```

When it builds successfully, you can run `./hl` to verify that it worked. Here’s the output that I see:

```haxe
HL/JIT 1.12.0 (c)2015-2020 Haxe Foundation
  Usage : hl [--debug <port>] [--debug-wait] <file>

```

Hopefully, this helps someone else!

---

<div class="post-metadata">

### Author: ![cpimhoff](https://community.haxe.org/user_avatar/community.haxe.org/cpimhoff/32/1902_2.png) [@cpimhoff](https://community.haxe.org/u/cpimhoff)
#### Post date: [May 23, 2022, 3:26am UTC](https://community.haxe.org/t/compiling-hashlink-on-macos-apple-silicon/3150/2 "2022-05-23T03:26:56Z")

</div>

Howdy hello! In case anybody else runs into an issue with this - the instructions here worked, but you may also need to modify `CFLAGS` and `LIBFLAGS` in the Makefile to reference `/usr/local/Homebrew` instead of `/usr/local`, since Homebrew may have placed the files inside a subdirectory.

---

<div class="post-metadata">

### Author: ![vlad\_may](https://community.haxe.org/user_avatar/community.haxe.org/vlad_may/32/2231_2.png) [@vlad\_may](https://community.haxe.org/u/vlad_may)
#### Post date: [September 12, 2023, 11:51pm UTC](https://community.haxe.org/t/compiling-hashlink-on-macos-apple-silicon/3150/3 "2023-09-12T23:51:35Z")

</div>

succesfully built 1.13 version on m1 mac! thanks!  
without CFLAGS and LIBFLAGS renaming everything worked perfectly.

```haxe
boroda$ ./hl
HL/JIT 1.13.0 (c)2015-2022 Haxe Foundation
  Usage : hl [--debug <port>] [--debug-wait] <file>

```

---

<div class="post-metadata">

### Author: ![tanis](https://community.haxe.org/user_avatar/community.haxe.org/tanis/32/2326_2.png) [@tanis](https://community.haxe.org/u/tanis)
#### Post date: [February 23, 2024, 2:27pm UTC](https://community.haxe.org/t/compiling-hashlink-on-macos-apple-silicon/3150/4 "2024-02-23T14:27:24Z")

</div>

Has there been any progress in making the VSCode debugger work on Apple Silicon now that HashLink compiles flawlessly on that architecture?

---

<div class="post-metadata">

### Author: ![okaybmd](https://community.haxe.org/user_avatar/community.haxe.org/okaybmd/32/2355_2.png) [@okaybmd](https://community.haxe.org/u/okaybmd)
#### Post date: [June 3, 2024, 1:35pm UTC](https://community.haxe.org/t/compiling-hashlink-on-macos-apple-silicon/3150/5 "2024-06-03T13:35:05Z")

</div>

Hi! I also managed to build hl for my Mac: MacBook Air with M1 processor, macOS Sonoma OS (14.5). I’m leaving here for posterity, full steps, compiled from other sources as well (since those needed to be adjusted for Sonoma anyway).

Please note that this setup works after I already have a regular version of homebrew installed, and a hl compiled (that does NOT work), however, this way is easier because you don’t need to make any edits to flags (as @cpimhoff is saying above).

1. Open a NEW terminal, check the current architecture by typing:  
`arch`  
Will say something like `arm64`

2. We need to make it say “i386”. Now, since we can’t duplicate the terminal shortcut in Sonoma, as other older tutorials say, all we can do is close this terminal, right-click the terminal shortcut (from Finder \> Applications \> Utilities \> Terminal, select “Get info”. We’ll see a pop-up with a checkbox that says “ **Open using Rosetta** ”, mark it as checked, close this pop-up, and double-click it to open a new terminal. Now, when we type “`arch`” again, should say `i386`

3. Navigate to the desired new install folder (I just installed it at the default path, which is user home (“~”), not ideal, but seems to work fine), create a new folder (I’m using hl\_i386, but you can use anything you want), then enter it:

```haxe
mkdir hl_i386
cd hl_i386

```

1. Install the Intel version of Homebrew, as above:

`arch -x86_64 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"`

1. Get the last HashLink source:  
`git clone https://github.com/HaxeFoundation/hashlink.git`

5b. Enter the folder

`cd hashlink`

1. Build hash link (as above):

```haxe
arch -x86_64 /usr/local/bin/brew bundle
arch -x86_64 make

```

1. Create Hello World example (right in this folder, not cool, but this is how I did it):  
`nano Main.hx`

7b. Add this content to the new file:

```haxe
class Main {
    static public function main():Void {
        // Single line comment
        trace("Hello World");
    }
}

```

1. Also create this file:  
`nano compile.hxml`

8b. Add this content:

```haxe
-cp src
-lib heaps
-lib hlsdl
-hl hello.hl
-main Main

```

1. Compile it:

`haxe --hl hello8.hl --main Main`

1. Run it. _Make sure to use **THIS** new path for hl, my mistake was that I was trying to run it using `hl hello8.hl` which was WRONG, because I already had a different HashLink on my system (the wrong one) and it was using it, even if I was in the proper folder, where the new hl was installed! Seems like PATH on a Mac comes before the current folder. So the proper instruction was:_

`./hl hello8.hl`

Which prints “`Hello World`”. Finally!

1. You can also disable rosetta from the terminal shortcut.

2. And maybe edit the PATH to use the new hl. And remove the “hello world” related files if you did as me 🙂

That’s it! Not very clean, but it works 😃

---

<div class="post-metadata">

### Author: ![okaybmd](https://community.haxe.org/user_avatar/community.haxe.org/okaybmd/32/2355_2.png) [@okaybmd](https://community.haxe.org/u/okaybmd)
#### Post date: [June 3, 2024, 1:46pm UTC](https://community.haxe.org/t/compiling-hashlink-on-macos-apple-silicon/3150/6 "2024-06-03T13:46:44Z")

</div>

I forgot to mention that building HL gives some warnings, but worry not, it still works as a charm 😉

---

<div class="post-metadata">

### Author: ![yz-xlame](https://community.haxe.org/user_avatar/community.haxe.org/yz-xlame/32/2334_2.png) [@yz-xlame](https://community.haxe.org/u/yz-xlame)
#### Post date: [August 15, 2024, 6:42am UTC](https://community.haxe.org/t/compiling-hashlink-on-macos-apple-silicon/3150/7 "2024-08-15T06:42:23Z")

</div>

macbook pro m1 sonoma 14.6.1:  
brew install [hashlink/Brewfile at master · HaxeFoundation/hashlink · GitHub](https://github.com/HaxeFoundation/hashlink/blob/master/Brewfile)  
then clone hashlink  
then `make` and `make install`

 ![截屏2024-08-15 14.41.13](https://community.haxe.org/uploads/default/original/2X/8/84da832fdb466f25b6facc184dd0d85347a75144.png)  
look like is fine

---

<div class="post-metadata">

### Author: ![yz-xlame](https://community.haxe.org/user_avatar/community.haxe.org/yz-xlame/32/2334_2.png) [@yz-xlame](https://community.haxe.org/u/yz-xlame)
#### Post date: [August 15, 2024, 8:42am UTC](https://community.haxe.org/t/compiling-hashlink-on-macos-apple-silicon/3150/8 "2024-08-15T08:42:34Z")

</div>

You may encounter such a problem. I tried to change to arch -x86\_64

> <https://github.com/HeapsIO/heaps/issues/1226>
>
> \### error
> \`\`\`
> heaps/git/h3d/impl/GlDriver.hx:223: characters 11-23 : Class\<sdl….Sdl\> has no field setGLVersion
> \`\`\`
> \### version: 
> \`\`\`
> haxe 4.3.6
> heaps 2
> hlsdl 1.14
> hasklink 1.14
> macbook pro m1 14.6.1
> \`\`\`
> 
> same issue: \[929\](https://github.com/HeapsIO/heaps/issues/929)
> I have seen that hashlinks exist, why is there an error message?

---

<div class="post-metadata">

### Author: ![min-pascal](https://community.haxe.org/user_avatar/community.haxe.org/min-pascal/32/2289_2.png) [@min-pascal](https://community.haxe.org/u/min-pascal)
#### Post date: [December 28, 2024, 9:59pm UTC](https://community.haxe.org/t/compiling-hashlink-on-macos-apple-silicon/3150/9 "2024-12-28T21:59:49Z")

</div>

I am having trouble at step 6. Despite running “arch -x86\_64 make” libraries are still being fetched from opt/homebrew

---

<div class="post-metadata">

### Author: ![Geokureli](https://community.haxe.org/user_avatar/community.haxe.org/geokureli/32/256_2.png) [@Geokureli](https://community.haxe.org/u/Geokureli)
#### Post date: [February 21, 2025, 6:47pm UTC](https://community.haxe.org/t/compiling-hashlink-on-macos-apple-silicon/3150/10 "2025-02-21T18:47:12Z")

</div>

this happened to me, when I closed the terminal to open a new one with rosetta I needed to quit the terminal program, not just close

---

<div class="post-metadata">

### Author: ![Geokureli](https://community.haxe.org/user_avatar/community.haxe.org/geokureli/32/256_2.png) [@Geokureli](https://community.haxe.org/u/Geokureli)
#### Post date: [February 21, 2025, 7:06pm UTC](https://community.haxe.org/t/compiling-hashlink-on-macos-apple-silicon/3150/11 "2025-02-21T19:06:11Z")

</div>

[solved] I seem to be having issues

running `./hl` shows:

> Usage : hl [–debug] [–debug-wait]

but `arch -x86_64 make` shows:

> When building HashLink from source, you must run `make codesign_osx` before installing.

so i ran `arch -x86_64 make codesign_osx` which shows a bunch of successful looking stuff followed by `1 key imported.`

but `lime setup hashlink` still tells me to run `make codesign_osx` again. I also tried `make codesign_osx` without `arch -x86_64`, just in case. Was I supposed to sign this in an earlier step?

Is steps 7+ just verifying that it works, or is that needed?

Edit: Talked to Josh in discord:

> Lime always says that when you have a custom HL\_PATH  
> it doesn’t check if it’s signed or anything

The actual issue was that dragging the hashlink folder into terminal for the `lime setup hashlink` path adds a space which was used in the path. I removed the space and i can compile hl now

Thanks all!

---

<div class="post-metadata">

### Author: ![antoniobrandao](https://community.haxe.org/user_avatar/community.haxe.org/antoniobrandao/32/2464_2.png) [@antoniobrandao](https://community.haxe.org/u/antoniobrandao)
#### Post date: [May 22, 2025, 12:56pm UTC](https://community.haxe.org/t/compiling-hashlink-on-macos-apple-silicon/3150/12 "2025-05-22T12:56:20Z")

</div>

> [@okaybmd](#):
>
> `arch -x86_64 make`

Everything seems ok until I run `arch -x86_64 make`

I get an error that stops the process, hl doesn’t get compiled

`ld: symbol(s) not found for architecture x86_64´ ´clang: error: linker command failed with exit code 1 (use -v to see invocation)`

In the log I see  
`ld: warning: ignoring file '/opt/homebrew/lib/libvorbisfile.dylib': found architecture 'arm64', required architecture 'x86_64'`

Seems that it isn’t using the intel homebrew afterall… but the previous command worked fine : `arch -x86_64 /usr/local/bin/brew bundle `

**EDIT:**  
Fixed it by hard-coding the 2 brew prefixes in the Makefile:

`BREW_PREFIX = $(shell brew --prefix)`  
`# prefixes for keg-only packages`  
`BREW_OPENAL_PREFIX := $(shell brew --prefix openal-soft)`

Changed to:

`BREW_PREFIX=/usr/local`  
`# prefixes for keg-only packages`  
`BREW_OPENAL_PREFIX=/usr/local/opt/openal-soft`

 ![image](https://community.haxe.org/uploads/default/original/2X/f/fedc735c1f0e1c7db12203af5a9e97b6c462d4b7.png)
