compiling HashLink on OSX

254 views
Skip to first unread message

theRemix

unread,
Nov 25, 2016, 6:14:51 PM11/25/16
to Haxe
when i attempt to compile, i get these errors.
how can i fix the undefined symbols error?

make                
cc -o libhl.dylib -m64  -L/usr/local/opt/jpeg-turbo/lib -L/usr/local/lib -shared include/pcre/pcre_chartables.o include/pcre/pcre_compile.o include/pcre/pcre_dfa_exec.o include/pcre/pcre_exec.o include/pcre/pcre_fullinfo.o include/pcre/pcre_globals.o include/pcre/pcre_newline.o include/pcre/pcre_string_utils.o include/pcre/pcre_tables.o include/pcre/pcre_xclass.o src/alloc.o src/std/array.o src/std/buffer.o src/std/bytes.o src/std/cast.o src/std/date.o src/std/error.o src/std/file.o src/std/fun.o src/std/maps.o src/std/math.o src/std/obj.o src/std/random.o src/std/regexp.o src/std/socket.o src/std/string.o src/std/sys.o src/std/types.o src/std/ucs2.o
echo 64
64
cc -Wall -O3 -I src -msse2 -mfpmath=sse -std=c11 -I include/pcre -D LIBHL_EXPORTS -m64 -I /usr/local/opt/jpeg-turbo/include -I /usr/local/include -o hl src/callback.o src/code.o src/jit.o src/main.o src/module.o -L. -lhl -ldl -Wl,-export_dynamic -L/usr/local/lib
cc -Wall -O3 -I src -msse2 -mfpmath=sse -std=c11 -I include/pcre -D LIBHL_EXPORTS -m64 -I /usr/local/opt/jpeg-turbo/include -I /usr/local/include -shared -o fmt.hdll libs/fmt/fmt.o  -L/usr/local/opt/jpeg-turbo/lib -L/usr/local/lib -lpng -lturbojpeg -lz
Undefined symbols for architecture x86_64:
  "_hl_alloc_buffer", referenced from:
      _fmt_inflate_init in fmt.o
      _zlib_error in fmt.o
      _fmt_deflate_init in fmt.o
  "_hl_alloc_dynamic", referenced from:
      _fmt_inflate_init in fmt.o
      _zlib_error in fmt.o
      _fmt_deflate_init in fmt.o
  "_hl_buffer_char", referenced from:
      _zlib_error in fmt.o
  "_hl_buffer_content", referenced from:
      _fmt_inflate_init in fmt.o
      _zlib_error in fmt.o
      _fmt_deflate_init in fmt.o
  "_hl_buffer_cstr", referenced from:
      _fmt_inflate_init in fmt.o
      _zlib_error in fmt.o
      _fmt_deflate_init in fmt.o
  "_hl_buffer_val", referenced from:
      _fmt_inflate_init in fmt.o
      _zlib_error in fmt.o
      _fmt_deflate_init in fmt.o
  "_hl_error_msg", referenced from:
      _fmt_png_decode in fmt.o
      _fmt_zip_flush_mode in fmt.o
      _fmt_inflate_buffer in fmt.o
      _fmt_deflate_buffer in fmt.o
  "_hl_gc_alloc_gen", referenced from:
      _fmt_inflate_init in fmt.o
      _fmt_deflate_init in fmt.o
  "_hl_throw", referenced from:
      _fmt_inflate_init in fmt.o
      _zlib_error in fmt.o
      _fmt_deflate_init in fmt.o
  "_hlt_bytes", referenced from:
      _fmt_inflate_init in fmt.o
      _zlib_error in fmt.o
      _fmt_deflate_init in fmt.o
  "_hlt_i32", referenced from:
      _fmt_inflate_init in fmt.o
      _zlib_error in fmt.o
      _fmt_deflate_init in fmt.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [fmt] Error 1


it still produces an hl and libhl.dylib binary, however it does not run properly

./hl
HL/JIT 0.1.0 (c)2015-2016 Haxe Foundation
  Usage : hl <file>

./hl main.hl
[1]    45466 segmentation fault  ./hl main.hl


hashlink.git [master] daa459269e0a1af8ad46e9b26bbe2b6ddea2f364
GNU Make 3.81
Apple LLVM version 7.3.0 (clang-703.0.31)
Target: x86_64-apple-darwin15.5.0
Thread model: posix

Haxiomic

unread,
Nov 26, 2016, 10:48:05 AM11/26/16
to Haxe
I think the 64 bit version is still a WIP, try running

make ARCH=64

Haxiomic

unread,
Nov 26, 2016, 10:49:54 AM11/26/16
to Haxe
Sorry, typo in the last email, I meant I try building the 32bit version:

make ARCH=32

theRemix

unread,
Nov 26, 2016, 8:22:35 PM11/26/16
to Haxe
i am getting more errors building for 32bit

make ARCH=32
cc -o libhl.dylib -m32  -L/usr/local/opt/jpeg-turbo/lib -L/usr/local/lib -shared include/pcre/pcre_chartables.o include/pcre/pcre_compile.o include/pcre/pcre_dfa_exec.o include/pcre/pcre_exec.o include/pcre/pcre_fullinfo.o include/pcre/pcre_globals.o include/pcre/pcre_newline.o include/pcre/pcre_string_utils.o include/pcre/pcre_tables.o include/pcre/pcre_xclass.o src/alloc.o src/std/array.o src/std/buffer.o src/std/bytes.o src/std/cast.o src/std/date.o src/std/error.o src/std/file.o src/std/fun.o src/std/maps.o src/std/math.o src/std/obj.o src/std/random.o src/std/regexp.o src/std/socket.o src/std/string.o src/std/sys.o src/std/types.o src/std/ucs2.o
ld: warning: ld: warning: ignoring file include/pcre/pcre_compile.o, file was built for x86_64 which is not the architecture being linked (i386): include/pcre/pcre_compile.oignoring file include/pcre/pcre_chartables.o, file was built for x86_64 which is not the architecture being linked (i386): include/pcre/pcre_chartables.o

ld: warning: ignoring file include/pcre/pcre_dfa_exec.o, file was built for x86_64 which is not the architecture being linked (i386): include/pcre/pcre_dfa_exec.o
ld: warning: ignoring file include/pcre/pcre_exec.o, file was built for x86_64 which is not the architecture being linked (i386): include/pcre/pcre_exec.o
ld: warning: ignoring file include/pcre/pcre_fullinfo.o, file was built for x86_64 which is not the architecture being linked (i386): include/pcre/pcre_fullinfo.o
ld: warning: ignoring file include/pcre/pcre_globals.o, file was built for x86_64 which is not the architecture being linked (i386): include/pcre/pcre_globals.o
ld: warning: ignoring file include/pcre/pcre_newline.o, file was built for x86_64 which is not the architecture being linked (i386): include/pcre/pcre_newline.o
ld: warning: ignoring file include/pcre/pcre_tables.o, file was built for x86_64 which is not the architecture being linked (i386): include/pcre/pcre_tables.o
ld: warning: ignoring file include/pcre/pcre_string_utils.o, file was built for x86_64 which is not the architecture being linked (i386): include/pcre/pcre_string_utils.o
ld: warning: ignoring file include/pcre/pcre_xclass.o, file was built for x86_64 which is not the architecture being linked (i386): include/pcre/pcre_xclass.o
ld: warning: ignoring file src/alloc.o, file was built for x86_64 which is not the architecture being linked (i386): src/alloc.o
ld: warning: ignoring file src/std/array.o, file was built for x86_64 which is not the architecture being linked (i386): src/std/array.o
ld: warning: ignoring file src/std/buffer.o, file was built for x86_64 which is not the architecture being linked (i386): src/std/buffer.o
ld: warning: ignoring file src/std/bytes.o, file was built for x86_64 which is not the architecture being linked (i386): src/std/bytes.o
ld: warning: ignoring file src/std/cast.o, file was built for x86_64 which is not the architecture being linked (i386): src/std/cast.o
ld: warning: ld: warning: ld: warning: ld: warning: ld: warning: ld: warning: ignoring file src/std/date.o, file was built for x86_64 which is not the architecture being linked (i386): src/std/date.oignoring file src/std/file.o, file was built for x86_64 which is not the architecture being linked (i386): src/std/file.oignoring file src/std/error.o, file was built for x86_64 which is not the architecture being linked (i386): src/std/error.oignoring file src/std/fun.o, file was built for x86_64 which is not the architecture being linked (i386): src/std/fun.oignoring file src/std/math.o, file was built for x86_64 which is not the architecture being linked (i386): src/std/math.oignoring file src/std/maps.o, file was built for x86_64 which is not the architecture being linked (i386): src/std/maps.old: warning:

ld: warning:



ignoring file src/std/random.o, file was built for x86_64 which is not the architecture being linked (i386): src/std/random.oignoring file src/std/obj.o, file was built for x86_64 which is not the architecture being linked (i386): src/std/obj.o
ld: warning: ld: warning: ld: warning: ld: warning: ld: warning:
ignoring file src/std/regexp.o, file was built for x86_64 which is not the architecture being linked (i386): src/std/regexp.oignoring file src/std/socket.o, file was built for x86_64 which is not the architecture being linked (i386): src/std/socket.old: warning: ignoring file src/std/string.o, file was built for x86_64 which is not the architecture being linked (i386): src/std/string.oignoring file src/std/sys.o, file was built for x86_64 which is not the architecture being linked (i386): src/std/sys.oignoring file src/std/types.o, file was built for x86_64 which is not the architecture being linked (i386): src/std/types.o

ignoring file src/std/ucs2.o, file was built for x86_64 which is not the architecture being linked (i386): src/std/ucs2.o



echo 32
32
cc -Wall -O3 -I src -msse2 -mfpmath=sse -std=c11 -I include/pcre -D LIBHL_EXPORTS -m32 -I /usr/local/opt/jpeg-turbo/include -I /usr/local/include -o hl src/callback.o src/code.o src/jit.o src/main.o src/module.o -L. -lhl -ldl -Wl,-export_dynamic -L/usr/local/lib
ld: warning: ignoring file src/callback.o, file was built for x86_64 which is not the architecture being linked (i386): src/callback.o
ld: warning: ignoring file src/code.o, file was built for x86_64 which is not the architecture being linked (i386): src/code.o
ld: warning: ld: warning: ignoring file src/jit.o, file was built for x86_64 which is not the architecture being linked (i386): src/jit.oignoring file src/main.o, file was built for x86_64 which is not the architecture being linked (i386): src/main.o

ld: warning: ignoring file src/module.o, file was built for x86_64 which is not the architecture being linked (i386): src/module.o
Undefined symbols for architecture i386:
  "_main", referenced from:
     implicit entry/start for main executable
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [hl] Error 1

is there something i must configure to make 32bit ARCH build properly?

Haxiomic

unread,
Nov 26, 2016, 8:57:41 PM11/26/16
to Haxe
Run `make clean` to remove the previously compiled 64 bit binaries

Any linker errors involving SDL, PNG or jpeg-turbo can be ignored and the hl binary will still be built, this is because these libraries are used in hl extensions like "fmt.hdll", which you can get away with not having to just tinker with hl. Nevertheless, if you want to clear these dependency linker errors, install 32-bit versions of the libraries: if you're using brew, you can usually add `--universal` to achieve this `brew install libpng --universal` will install the 32/64 universal binaries. This will work for libpng and sdl2, but for jpeg-turbo you'll probably need to install the 32-bit versions another way since it's not available via brew

theRemix

unread,
Nov 26, 2016, 9:10:23 PM11/26/16
to Haxe
awesome, that works! thanks Haxiomic
Reply all
Reply to author
Forward
0 new messages