Compiling a binary release for macOS

I’ve been doing some work with Haxe/Heaps and I now want to build an app bundle for macOS/OSX.

So far I’ve done the following:

haxe -m Main --hl out/main.c -lib heaps -lib hlsdl -resource res/level.json@level

That gets me a bunch of C code.

I can then load that C code into Xcode. Fetch in the .hdll and .dylib files from the Hashlink project and build it.

When I run the resulting app bundle I get:

Dyld Error Message:
Library not loaded: fmt.hdll
Referenced from: /Users/USER/Library/Developer/Xcode/DerivedData/TestBundle2-fsryodfodzgjlabfezalbgocsvrz/Build/Products/Debug/
Reason: image not found

My understanding is that this is because you need to do a bunch of stuff with “install_name_tool” to correct various dyld paths in the binaries that Xcode generates. So far I’ve been unsuccessful in figuring out what the magic incantations are to do this.

  1. Am I going about building a macOS app bundle the correct way?
  2. If I am going about this the right way how do you correctly include the Hashlink libraries in the app bundle?


Hey @patricknr, you shouldn’t need to mess around with install_name_tool. I’ve not tried compiling hashlink output it for a while and it may have changed but there’s a thread that might be useful here: Problems with compiling the hl/c output. · Issue #86 · HaxeFoundation/hashlink · GitHub

I think compiling via xcode complicates things, you should be able to compile via a single clang call

I think the plan is to eventually have this done automatically but for now it’s a bit hands-on!

From the hashlink website

haxe -hl out/main.c -main MyApp
gcc -O3 -o myapp -std=c11 -I out out/main.c -Lhl [/path/to/required.hdll]