Hermanverschooten

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

Hermanverschooten

nvm that, I had set the :otp_app to :zigler :man_facepalming:

Still causes the same mach-o error.

Also Liked

Hermanverschooten

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

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.

Where Next?

Popular in Questions Top

minhajuddin
I have seen a lot of code which picks the first element from a list using Enum.at(0) instead of List.first. Is there a reason why people ...
New
hariharasudhan94
Lets say I have map like this fetching from my database %{"_id" => #BSON.ObjectId<58eb1a7a9ad169198c3dXXXX>, "email" => ...
New
lastday4you
I wanted to check elixir version in phoenix because i found that my elixir is 1.5 but when i use Enum.chunk_by it said the function is un...
New
Lily
In templates/appointment/index.html.eex: <%= for appointment <- @appointments do %> <tr> <td><%= appoi...
New
greenz1
I have a phoenix application from which a user can download multiple(5-6) files of size 1MB. I couldn’t find anything related to sending ...
New
aalberti333
As the title describes, I’m trying to run Enum.map() over a list of key/value pairs, where the value is a map. My data looks like this: ...
New
JorisKok
I have a server on AWS, and was running a load test using artillery. When looking at the Phoenix dashboard I see the Ports going to 100% ...
New

Other popular topics Top

minhajuddin
I have seen a lot of code which picks the first element from a list using Enum.at(0) instead of List.first. Is there a reason why people ...
New
New
chrismccord
Phoenix 1.4.0 released Phoenix 1.4 is out! This release ships with exciting new features, most notably with HTTP2 support, improved deve...
688 31494 112
New
gausby
I asked this very same question on twitter and got some interesting feedback, but I thought it would be a good question to ask here as we...
1207 40042 209
New
alice
Hey, Just curious what are the main benefits of Elixir compared to Clojure? When is Elixir more useful than Clojure and vice versa? Th...
New
Patoshizzle
After calling mix ecto.create I get this error: 17:00:32.162 [error] GenServer #PID<0.412.0> terminating ** (Postgrex.Error) FATAL...
New

We're in Beta

About us Mission Statement