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.

Where Next?

Popular in Questions Top

marius95
Hello everyone, I try to use an Javascript Event Handler in my root.html.leex file. Therefore I created a function in the app.js file: ...
New
sen
Hi All, I set a environment variables in dev.exs , like below code. when i start server, how can i set the ${enable} value? thanks. d...
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
jaysoifer
Is there a way to rollback a specific migration and only that one ("skipping" all the other ones)? Would mix ecto.rollback -v 2008090...
New
JeremM34
Hello, how can I check the Phoenix version ? Thanks !
New
jerry
Good day to you all. I have been struggling to get a query involving like and ilike to work. Can anyone assist me on this, please? pro...
New
lucidguppy
I have a super simple question about elixir - how would I take a file like this foo bar baz and output a new file that enumerates th...
New
romenigld
I am trying to run a deploy with docker and I successfully runned with this command: docker build -t romenigld/blog-prod . but when I t...
New
dotdotdotPaul
Okay, I'm having a heck of a time trying to figure out how to best handle the validation of belongs_to associations in Ecto. I'm sure I'...
New
svb
Hi! Currently I want to submit a form by pressing the Enter key. However, since my input field is of type “textarea” this is just adds a...
New

Other popular topics Top

josevalim
Hi everyone, One of the features added to Elixir early on to help integration with Erlang code was the idea of overridable function defi...
New
pmjoe
I have a relationship of love and hate with Elixir. Lots of things are just absolutely right, but there are some things that are kind of ...
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 39247 209
New
chrismccord
This release brings a number of exciting features, including integration with the new Phoenix LiveDashboard and Phoenix LiveView. There h...
New
fayddelight
I tried installing elixir 1.11.2 erlang 23.3.4 via asdf in my zsh shell. Enabled the versions locally and globally. When I list them ...
New
AngeloChecked
What learn first? Rust or Elixir Hi Elixir community! I’m here because i want learn a new language. I’m a junior developer and mainly i ...
New
KronicDeth
Elixir plugin for JetBrain’s IntelliJ Platform (including Rubymine) This is a plugin that adds support for Elixir to JetBrains IntelliJ...
289 35953 110
New
marick
I had some trouble figuring out how to make many-to-many associations work. Once I got it working, I wrote a blog post. Because I'm a nov...
New
jononomo
For some reason my phoenix channels are working for me in my local dev environment, but as soon as I deploy via Docker, I get a 403 error...
New
vonH
In asking this question I am more interested about the expressiveness of the language itself and less concerned about the availability of...
New

We're in Beta

About us Mission Statement