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).
-
Open a NEW terminal, check the current architecture by typing:
arch
Will say something likearm64
-
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 sayi386
-
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:
mkdir hl_i386
cd hl_i386
- 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)"
- Get the last HashLink source:
git clone https://github.com/HaxeFoundation/hashlink.git
5b. Enter the folder
cd hashlink
- Build hash link (as above):
arch -x86_64 /usr/local/bin/brew bundle
arch -x86_64 make
- 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:
class Main {
static public function main():Void {
// Single line comment
trace("Hello World");
}
}
- Also create this file:
nano compile.hxml
8b. Add this content:
-cp src
-lib heaps
-lib hlsdl
-hl hello.hl
-main Main
- Compile it:
haxe --hl hello8.hl --main Main
- 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!
-
You can also disable rosetta from the terminal shortcut.
-
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