Issues trying to produce a Mac OSX binary

Started by namida, December 02, 2017, 08:58:11 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

namida

When trying to compile on Mac, although it compiles fine, I get the following error when trying to run it (it seems that it gets run at the end of compilation; a binary is produced that when run gives the same output as the line starting with "dyld" onwards).

Namidas-Mac-mini:lix namida$ dub -b release
Performing "release" build using dmd for x86_64.
allegro 4.0.1+5.2.0: target for configuration "no-libs" is up to date.
derelict-util 2.1.0: target for configuration "library" is up to date.
derelict-enet 2.0.0: target for configuration "library" is up to date.
enumap 0.4.1: target for configuration "library" is up to date.
lix 0.9.4: target for configuration "application" is up to date.
To force a rebuild of up-to-date targets, run again with --force.
Running ./bin/lix
dyld: Symbol not found: __al_mangled_main
  Referenced from: /usr/local/opt/allegro/lib/liballegro_main.5.2.dylib
  Expected in: flat namespace
in /usr/local/opt/allegro/lib/liballegro_main.5.2.dylib
Program exited with code -6


Some Googling suggests this is due to special requirements regarding event handlers on OSX, so Allegro basically makes itself the main thread and runs the user code in a sub-thread. This is known to fail on main functions that don't have a very specific set of arguments - however, D does not seem to allow changing them to the "correct" ones (and this would probably break other code anyway).

One other solution suggested is to link Allegro to the binary statically rather than dynamically. I have yet to figure out how to do this, but it does seem to involve compiling Allegro myself - which in turn will not properly compile against Mac OSX 10.13 system libraries. (As such, my current task is to figure out how to compile it against older system libraries, without resorting to actually installing an older version of OSX on my system.)

One last suggestion I've seen is not to strip the labels from the executable. I'm not deliberately doing that, and would have no idea how to explicitly tell dub / DMD not to do so (I did try googling this, but the few relevant responses I could find seem to imply D doesn't do this automatically).
My projects
2D Lemmings: NeoLemmix (engine) | Lemmings Plus Series (level packs) | Doomsday Lemmings (level pack)
3D Lemmings: Loap (engine) | L3DEdit (level / graphics editor) | L3DUtils (replay / etc utility) | Lemmings Plus 3D (level pack)
Non-Lemmings: Commander Keen: Galaxy Reimagined (a Commander Keen fangame)

Forestidia86

#1
This seems to be basically this issue:
issue 278
Issue description contains possible solution (found by new user spacetag (in Lix IRC)):

"Lix 0.9.6

spacetag has built Lix on Mac. This works with stable dmd, but fails at runtime with a linker problem:

dyld: Symbol not found: __al_mangled_main

Solution: Remove the linkage against allegro_main from dub." [As far as I've understood it, this means to take "allegro_main", out of dub.json.]

Simon

Wow, I forgot that namida posted this thread recently. I've never even replied. <_< I'm sorry.

Yeah, spacetag ran into the same issue, and Forestidia has explained his solution.

-- Simon