I am looking to get the nimler module (https://github.com/wltsmrz/nimler) working on macOS and when executing the compile step I get the following errors:
Undefined symbols for architecture x86_64: "_enif_get_long", referenced from: _fromTerm__nim95elixir95test_43 in @mnim_elixir_test.nim.c.o "_enif_make_badarg", referenced from: _zadd__nim95elixir95test_33 in @mnim_elixir_test.nim.c.o "_enif_make_long", referenced from: _toTerm__OOZOOZOOZOOZOOZOnimbleZpkgsZnimler4552O54O48ZnimlerZcodec_146 in @mnim_elixir_test.nim.c.o ld: symbol(s) not found for architecture x86_64
I am not super experienced in C or Nim so some help would be appreciated :)
I believe that is done by the library:
'clang -shared -o /Users/JSONBash/work/monto/elixir/nim-elixir-test/src/libnim_elixir_test.dylib /Users/JSONBash/.cache/nim/nim_elixir_test_d/stdlib_digitsutils.nim.c.o /Users/JSONBash/.cache/nim/nim_elixir_test_d/stdlib_assertions.nim.c.o /Users/JSONBash/.cache/nim/nim_elixir_test_d/stdlib_dollars.nim.c.o /Users/JSONBash/.cache/nim/nim_elixir_test_d/stdlib_system.nim.c.o /Users/JSONBash/.cache/nim/nim_elixir_test_d/stdlib_posix.nim.c.o /Users/JSONBash/.cache/nim/nim_elixir_test_d/stdlib_times.nim.c.o /Users/JSONBash/.cache/nim/nim_elixir_test_d/@mnim_elixir_test.nim.c.o -lm -lm -dynamiclib -ldl'
This is where the linker fails
I solved getting it to work on my mac with M1, thanks to treeform for helping with the nimble file. My project is named nim_elixir_test, so for anyone in the future you should just need to change that name:
task bindings, "Generate Bindings": proc compile(libName: string, flags = "") = exec "nim c -f " & flags & " -d:release --app:lib --gc:arc -d:nimlerGenWrapper --passL:'- undefined dynamic_lookup' --out:" & libName & " --outdir:bindings/generated src/nim_elixir_test.nim" when defined(windows): compile "nim_elixir-test.dll" elif defined(macosx): compile "libnim_elixir_test.dylib.arm", "--cpu:arm64 -l:'-target arm64-apple-macos11' -t:'-target arm64-apple-macos11'" compile "libnim_elixir_test.dylib.x64", "--cpu:amd64 -l:'-target x86_64-apple-macos10.12' -t:'-target x86_64-apple-macos10.12'" exec "lipo bindings/generated/libnim_elixir_test.dylib.arm bindings/generated/libnim_elixir_test.dylib.x64 -output bindings/generated/libnim_elixir_test.dylib -create" exec "mv bindings/generated/libnim_elixir_test.dylib src/libnim_elixir_test.dylib.arm.so && mv bindings/generated/NumberAdder.ex src/NumberAdder.ex" else: compile "libnim_elixir_test.so"
The important parts to note: