Hermanverschooten
Zigler with Nerves - not a mach-o file
I am trying to use a very simple zig function in my Nerves app, but it isn’t working.
First I get an error:
Error while loading project :zigler at /Users/herman/Projects/GratWiFi/nerves/firmware/deps/zigler
The firmware compilation continues, I can see zig building my file, but the it errors out:
10:30:00.943 [info] searching for zig in /Users/herman/Library/Caches/zigler/zig-macos-aarch64-0.13.0/zig
10:30:00.945 [info] zig expected (via cache) in /Users/herman/Library/Caches/zigler/zig-macos-aarch64-0.13.0/zig
10:30:00.945 [debug] running command: /Users/herman/Library/Caches/zigler/zig-macos-aarch64-0.13.0/zig fmt /var/folders/01/8bmlqt_922q399bvltpk4z7h0000gn/T/Elixir.GratWiFi.Zig.Datetime/build.zig
10:30:00.990 [debug] wrote build.zig to /var/folders/01/8bmlqt_922q399bvltpk4z7h0000gn/T/Elixir.GratWiFi.Zig.Datetime/build.zig
10:30:00.998 [info] searching for zig in /Users/herman/Library/Caches/zigler/zig-macos-aarch64-0.13.0/zig
10:30:00.998 [info] zig expected (via cache) in /Users/herman/Library/Caches/zigler/zig-macos-aarch64-0.13.0/zig
10:30:00.998 [debug] running command: /Users/herman/Library/Caches/zigler/zig-macos-aarch64-0.13.0/zig run -lc --dep analyte -Mmain=/Users/herman/Projects/GratWiFi/nerves/firmware/_build/gratwifi_rpi5_dev/lib/zigler/priv/beam/sema.zig -Merl_nif=/Users/herman/Projects/GratWiFi/nerves/firmware/_build/gratwifi_rpi5_dev/lib/zigler/priv/beam/stub_erl_nif.zig --dep erl_nif -Mbeam=/Users/herman/Projects/GratWiFi/nerves/firmware/_build/gratwifi_rpi5_dev/lib/zigler/priv/beam/beam.zig -Mattributes=/var/folders/01/8bmlqt_922q399bvltpk4z7h0000gn/T/Elixir.GratWiFi.Zig.Datetime/attributes.zig --dep erl_nif --dep beam --dep attributes -Manalyte=/Users/herman/Projects/GratWiFi/nerves/firmware/lib/gratwifi/zig/.Elixir.GratWiFi.Zig.Datetime.zig
10:30:01.797 [info] searching for zig in /Users/herman/Library/Caches/zigler/zig-macos-aarch64-0.13.0/zig
10:30:01.797 [info] zig expected (via cache) in /Users/herman/Library/Caches/zigler/zig-macos-aarch64-0.13.0/zig
10:30:01.797 [debug] running command: /Users/herman/Library/Caches/zigler/zig-macos-aarch64-0.13.0/zig fmt /var/folders/01/8bmlqt_922q399bvltpk4z7h0000gn/T/Elixir.GratWiFi.Zig.Datetime/module.zig
10:30:01.842 [debug] wrote module code to /var/folders/01/8bmlqt_922q399bvltpk4z7h0000gn/T/Elixir.GratWiFi.Zig.Datetime/module.zig
10:30:01.842 [info] searching for zig in /Users/herman/Library/Caches/zigler/zig-macos-aarch64-0.13.0/zig
10:30:01.842 [info] zig expected (via cache) in /Users/herman/Library/Caches/zigler/zig-macos-aarch64-0.13.0/zig
10:30:01.842 [debug] running command: /Users/herman/Library/Caches/zigler/zig-macos-aarch64-0.13.0/zig build -Doptimize=Debug --prefix /Users/herman/Projects/GratWiFi/nerves/firmware/_build/gratwifi_rpi5_dev/lib/zigler/priv
10:30:01.923 [debug] built library at /Users/herman/Projects/GratWiFi/nerves/firmware/_build/gratwifi_rpi5_dev/lib/zigler/priv/lib/Elixir.GratWiFi.Zig.Datetime.so
10:30:01.934 [error] loading module Elixir.GratWiFi.Zig.Datetime {:load_failed, ~c"Failed to load NIF library: 'dlopen(/Users/herman/Projects/GratWiFi/nerves/firmware/_build/gratwifi_rpi5_dev/lib/zigler/priv/lib/Elixir.GratWiFi.Zig.Datetime.so, 0x0002): tried: '/Users/herman/Projects/GratWiFi/nerves/firmware/_build/gratwifi_rpi5_dev/lib/zigler/priv/lib/Elixir.GratWiFi.Zig.Datetime.so' (not a mach-o file), '/System/Volumes/Preboot/Cryptexes/OS/Users/herman/Projects/GratWiFi/nerves/firmware/_build/gratwifi_rpi5_dev/lib/zigler/priv/lib/Elixir.GratWiFi.Zig.Datetime.so' (no such file), '/Users/herman/Projects/GratWiFi/nerves/firmware/_build/gratwifi_rpi5_dev/lib/zigler/priv/lib/Elixir.GratWiFi.Zig.Datetime.so' (not a mach-o file), '/Users/herman/Projects/GratWiFi/nerves/firmware/deps/zigler/priv/lib/Elixir.GratWiFi.Zig.Datetime.so' (not a mach-o file), '/System/Volumes/Preboot/Cryptexes/OS/Users/herman/Projects/GratWiFi/nerves/firmware/deps/zigler/priv/lib/Elixir.GratWiFi.Zig.Datetime.so' (no such file), '/Users/herman/Projects/GratWiFi/nerves/firmware/deps/zigler/priv/lib/Elixir.GratWiFi.Zig.Datetime.so' (not a mach-o file)'"}
The firmware gets build, but when you deploy it, it goes into a reboot-loop because it cannot find the nif file.
Thinking I somehow missed something, I downloaded the nerves-examples repo, and tried the hello-zig example, but this behaves the same.
I am on a Mac Mini M4, if that makes a difference.
Marked As Solved
Hermanverschooten
Also Liked
Hermanverschooten
Hey @D4no0, thanks for your feedback.
I tried zigler with a non-nerves project and that works just fine, it makes a .so and .dylib in _build/dev/lib/try_zig/priv/lib.
After fixing the :otp_app, it builds them in the “same” folder in my build tree as .so files.
So the cross-compiling works.
Last Post!
Hermanverschooten
Okay, much a do about nothing…
Correcting the :otp_app apparently also solved the reboot-loop.
There is still the error on :erlang.load_nif while building the firmware, but it works.
Popular in Questions
Other popular topics
Latest Nerves Threads
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #elixirconf-us
- #advent-of-code
- #distillery
- #processes
- #forms
- #api
- #metaprogramming
- #security
- #hex









