5

I am trying to install the executalbles to compile programs in HLA on a Mac OS 10.8. Although the tools seem to be in the right place and working I am getting the following error when trying to compile the first program

ld: warning: -macosx_version_min not specified, assuming 10.8
Undefined symbols for architecture i386:
  "_main", referenced from:
     implicit entry/start for main executable
ld: symbol(s) not found for architecture i386
Error returned by ld = 256

The hla executalbe seems to output the object file but something in the linker seems to not be working. I have previously managed to install it on other machines but in most cases I get this error.

Any ideas?

Mike M
  • 4,879
  • 5
  • 38
  • 58

1 Answers1

11

You can tell HLA to use "_main" as the entry point by using "-main:_main". You may also need to link with libSystem.dylib and get rid of some linker warnings, so that the whole command would be

hla -main:_main -l"macosx_version_min 10.9" -l"lSystem" -l"no_pie" source.hla

  • Is there a way I can add this somewhere so I don't have to type it into the terminal every time, or is that wishful thinking? – Brian Schermerhorn May 20 '16 at 00:22
  • 1
    I ended up adding a shell function in my .bashrc hlac() { hla -main:_main -l"macosx_version_min 10.9" -l"lSystem" -l"no_pie" $1; } – Brian Schermerhorn May 20 '16 at 00:33
  • It's possible to use XCode's build system with HLA. Create a project of type 'External Build Tool' and set the build tool to `/usr/bin/make`. Create a Makefile with the accepted answer's command line as the action for your target, add in the 'hlalib' and 'hlainc' to your build settings, as well as the path to the hla directory (PATH is `$(PATH):/path/to/hla`). Building should now produce a runnable binary in the source directory. You don't get syntax highlighting but you do get an IDE. Rinse and repeat with your Makefile to add in more files. – Robin Macharg Apr 30 '18 at 10:18