# Building haxe on mac m1

**URL:** https://community.haxe.org/t/building-haxe-on-mac-m1/3713
**Category:** Haxe
**Created:** [October 7, 2022, 2:01pm UTC](https://community.haxe.org/t/building-haxe-on-mac-m1/3713 "2022-10-07T14:01:36Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![romamik](https://community.haxe.org/user_avatar/community.haxe.org/romamik/32/345_2.png) [@romamik](https://community.haxe.org/u/romamik)
#### Post date: [October 7, 2022, 2:01pm UTC](https://community.haxe.org/t/building-haxe-on-mac-m1/3713/1 "2022-10-07T14:01:36Z")

</div>

I’m trying to build haxe from source on mac m1.  
I’m using these instructions: [haxe/BUILDING.md at development · HaxeFoundation/haxe · GitHub](https://github.com/HaxeFoundation/haxe/blob/development/extra/BUILDING.md)  
And I’m getting error:  
`mbedtls_stubs.c:23:10: fatal error: 'mbedtls/config.h' file not found`

I’ve installed mbedtls with homebrew and I have this file in “/opt/homebrew/include/mbedtls/debug.h”  
I think I need to pass C include path to dune, but I cannot find a way to do this. Also I will need to pass library path, so that it will find .a files for the libraries.

I’ve tried creating C\_INCLUDE\_PATH=/opt/homebrew/include environment variable but this did not help.

---

<div class="post-metadata">

### Author: ![romamik](https://community.haxe.org/user_avatar/community.haxe.org/romamik/32/345_2.png) [@romamik](https://community.haxe.org/u/romamik)
#### Post date: [October 7, 2022, 3:02pm UTC](https://community.haxe.org/t/building-haxe-on-mac-m1/3713/2 "2022-10-07T15:02:52Z")

</div>

I was able to fix this error by running something like

```haxe
   curl -L https://github.com/ARMmbed/mbedtls/archive/v$MBEDTLS_VERSION.tar.gz | tar xz
   cd mbedtls-$MBEDTLS_VERSION
   make && make install

```

I’ve found this in build-mac.yml file.  
I think it did put files to “/usr/local/include” and “/usr/local/lib” folders.

I’m now getting another compilation issues though…

---

<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: [October 7, 2022, 9:18pm UTC](https://community.haxe.org/t/building-haxe-on-mac-m1/3713/3 "2022-10-07T21:18:46Z")

</div>

I don’t know how different building HashLink is compared to the Haxe compiler, but I found that using the Apple Silicon version of Homebrew didn’t work to build HashLink. I needed to do some special things to force the HashLink build process use the Intel version of Homebrew instead.

So maybe there are similar requirements for the Haxe compiler. Here’s the thread where I posted my findings for HashLink. Maybe it’ll provide some clues:

> [@Compiling HashLink on macOS Apple Silicon](https://community.haxe.org/t/compiling-hashlink-on-macos-apple-silicon/3150):
>
> 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: 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…

---

<div class="post-metadata">

### Author: ![romamik](https://community.haxe.org/user_avatar/community.haxe.org/romamik/32/345_2.png) [@romamik](https://community.haxe.org/u/romamik)
#### Post date: [October 10, 2022, 1:56pm UTC](https://community.haxe.org/t/building-haxe-on-mac-m1/3713/4 "2022-10-10T13:56:39Z")

</div>

I’m not sure why, but it did not worked out with x86\_64 brew.  
But I’ve finally managed to build arm64 version, which is fine for me. That’s what has worked for me:

```haxe
brew install zlib
brew install pcre
brew install mbedtls@2
brew unlink mbedtls
brew link mbedtls@2
export CPATH="/opt/homebrew/include:/opt/homebrew/opt/zlib/include:$CPATH"
make STATICLINK=1 "LIB_PARAMS=/opt/homebrew/opt/zlib/lib/libz.a /opt/homebrew/lib/libpcre.a /opt/homebrew/lib/libmbedtls.a /opt/homebrew/lib/libmbedcrypto.a /opt/homebrew/lib/libmbedx509.a -cclib '-framework Security -framework CoreFoundation'"

```
