# 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:** 1\
**Showing post:** 5

<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 😃

---

_[View the full topic](https://community.haxe.org/t/compiling-hashlink-on-macos-apple-silicon/3150)._
