-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Compilation error when adding version "~> 5.0" to existing mix project #14
Comments
Mmhh I can't replicate, unfortunately. I can see in your pasted output that you have
Which should mean that the ex-portmidi NIFs were already compiled. Have you tried nuking the Thank you! 🙇♂️ |
Ok, I have managed to pinpoint this a little further. The problem seems to be specifically version 5.1.2, because 5.1.1 works fine. I believe the .so files that are included in the hex package for version 5.1.2 might not be the correct files. Or maybe you don't actually want these files included in the package because simply removing them and recompiling fixed the issue for me. So these are the steps I took to get 5.1.2 to work.
That triggered make to compile the files again and fixed the issue I had. |
Just wanted to report I see the same problem with 5.1.2:
I was able to install 5.1.1, though. |
I dug a bit deeper, installing the development version of
Then I downloaded the 2 versions locally:
Here is the recursive diff I got with diff -r portmidi-5.1.1/hex_metadata.config portmidi-5.1.2/hex_metadata.config
6,16c6,10
< [<<"priv/portmidi_devices.so">>,
< <<"priv/portmidi_devices.so.dSYM/Contents/Info.plist">>,
< <<"priv/portmidi_devices.so.dSYM/Contents/Resources/DWARF/portmidi_devices.so">>,
< <<"priv/portmidi_in.so">>,
< <<"priv/portmidi_in.so.dSYM/Contents/Info.plist">>,
< <<"priv/portmidi_in.so.dSYM/Contents/Resources/DWARF/portmidi_in.so">>,
< <<"priv/portmidi_out.so">>,
< <<"priv/portmidi_out.so.dSYM/Contents/Info.plist">>,
< <<"priv/portmidi_out.so.dSYM/Contents/Resources/DWARF/portmidi_out.so">>,
< <<"lib/mix/tasks/portmidi.devices.ex">>,<<"lib/portmidi.ex">>,
< <<"lib/portmidi/device.ex">>,<<"lib/portmidi/devices.ex">>,
---
> [<<"priv">>,<<"priv/.gitkeep">>,<<"priv/portmidi_devices.so">>,
> <<"priv/portmidi_in.so">>,<<"priv/portmidi_out.so">>,<<"lib">>,
> <<"lib/mix">>,<<"lib/mix/tasks">>,<<"lib/mix/tasks/portmidi.devices.ex">>,
> <<"lib/portmidi">>,<<"lib/portmidi.ex">>,<<"lib/portmidi/device.ex">>,
> <<"lib/portmidi/devices.ex">>,<<"lib/portmidi/input">>,
19,21c13,16
< <<"lib/portmidi/nifs/devices.ex">>,<<"lib/portmidi/nifs/input.ex">>,
< <<"lib/portmidi/nifs/output.ex">>,<<"lib/portmidi/output.ex">>,
< <<"src/erl_comm.c">>,<<"src/portmidi_devices.c">>,<<"src/portmidi_in.c">>,
---
> <<"lib/portmidi/nifs">>,<<"lib/portmidi/nifs/devices.ex">>,
> <<"lib/portmidi/nifs/input.ex">>,<<"lib/portmidi/nifs/output.ex">>,
> <<"lib/portmidi/output.ex">>,<<"src">>,<<"src/erl_comm.c">>,
> <<"src/portmidi_devices.c">>,<<"src/portmidi_in.c">>,
29c24
< {<<"version">>,<<"5.1.1">>}.
---
> {<<"version">>,<<"5.1.2">>}.
diff -r portmidi-5.1.1/lib/portmidi/device.ex portmidi-5.1.2/lib/portmidi/device.ex
8c8
< |> make_struct
---
> |> make_struct()
diff -r portmidi-5.1.1/lib/portmidi/devices.ex portmidi-5.1.2/lib/portmidi/devices.ex
6c6
< do_list
---
> do_list()
diff -r portmidi-5.1.1/lib/portmidi/input/server.ex portmidi-5.1.2/lib/portmidi/input/server.ex
24c24
< case Reader.start_link(self, device_name) do
---
> case Reader.start_link(self(), device_name) do
34c34
< self
---
> self()
36c36
< |> Enum.each(&(send(&1, {self, messages})))
---
> |> Enum.each(&(send(&1, {self(), messages})))
diff -r portmidi-5.1.1/lib/portmidi/input.ex portmidi-5.1.2/lib/portmidi/input.ex
13,27d12
< def stream!(input) do
< Listeners.register(input, self)
<
< Stream.resource(fn ->
< input
< end, fn(input) ->
< receive do
< {^input, events} -> {events, input}
< end
< end, fn(input) ->
< stop(input)
< end)
<
< end
<
diff -r portmidi-5.1.1/lib/portmidi/listeners.ex portmidi-5.1.2/lib/portmidi/listeners.ex
54a55
>
diff -r portmidi-5.1.1/mix.exs portmidi-5.1.2/mix.exs
3c3
< @version "5.1.1"
---
> @version "5.1.2"
10c10
< package: package,
---
> package: package(),
14c14
< deps: deps,
---
> deps: deps(),
31c31
< {:ex_doc, github: "elixir-lang/ex_doc", only: :dev},
---
> {:ex_doc, "~> 0.19", only: :dev, runtime: false},
44c44
< @shortdoc "Compiles portmidi bindings"
---
> @moduledoc "Compiles portmidi bindings"
48a49,50
>
> :ok
Only in portmidi-5.1.2/priv: .gitkeep
Binary files portmidi-5.1.1/priv/portmidi_devices.so and portmidi-5.1.2/priv/portmidi_devices.so differ
Only in portmidi-5.1.1/priv: portmidi_devices.so.dSYM
Binary files portmidi-5.1.1/priv/portmidi_in.so and portmidi-5.1.2/priv/portmidi_in.so differ
Only in portmidi-5.1.1/priv: portmidi_in.so.dSYM
Binary files portmidi-5.1.1/priv/portmidi_out.so and portmidi-5.1.2/priv/portmidi_out.so differ
Only in portmidi-5.1.1/priv: portmidi_out.so.dSYM
diff -r portmidi-5.1.1/src/portmidi_devices.c portmidi-5.1.2/src/portmidi_devices.c
14,16d13
< int* hey;
<
< I'm not yet well-versed in how the C extensions are compiled & loaded, yet, but at least a few differences stand out:
It looks like the published version has been constructed a bit differently. I'm on a Mac, fwiw. @lucidstack if you have some guidance, I can go a bit deeper :-) |
I investigated a bit more. Here are my findings. Explanation of the failureIf one installs It's possible to determine the architecture of the dynamic library this way:
This seem to indicate it's a Linux-based compiled file. If I run the fix provided by @drumusician, we get a different output:
Mach-O are Apple / Darwin executables. So this definitely confirms what @drumusician has hinted: the compiled binary hasn't got the right architecture. But how does this get compiled, at all?I was trying to determine what triggers the compilation, and it turns out it's not very explicit. It is simply This is documented here: https://hexdocs.pm/mix/Mix.Tasks.Deps.Compile.html How can we fix it in
|
It's also possible to use the latest version by just telling defp deps do
[
{:portmidi, git: "https://github.com/lucidstack/ex-portmidi.git"} |
I encountered this issue as well but the above suggestions did not fix it... Did anybody find a reliable fix after this time? |
Hey all! Getting PortMidi to work on M1 has been daunting. I had almost zero experience modifying Makefiles or working with C code, but I really wanted to get it working for an app I'm working on. In order to get portmidi to compile, I had to do things a little differently.
➜ ex-portmidi git:(master) ✗ make
cc -g -std=c99 -O3 -pedantic -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -target arm64-apple-macos11 -I /opt/homebrew/Cellar/portmidi/217_2/include -L /opt/homebrew/Cellar/portmidi/217_2/lib -I/Users/owen/.asdf/installs/erlang/24.1.4/erts-12.1.4/include -fPIC -shared -dynamiclib -undefined dynamic_lookup -o priv/portmidi_in.so -lportmidi src/portmidi_in.c src/portmidi_shared.c
cc -g -std=c99 -O3 -pedantic -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -target arm64-apple-macos11 -I /opt/homebrew/Cellar/portmidi/217_2/include -L /opt/homebrew/Cellar/portmidi/217_2/lib -I/Users/owen/.asdf/installs/erlang/24.1.4/erts-12.1.4/include -fPIC -shared -dynamiclib -undefined dynamic_lookup -o priv/portmidi_out.so -lportmidi src/portmidi_out.c src/portmidi_shared.c
cc -g -std=c99 -O3 -pedantic -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -target arm64-apple-macos11 -I /opt/homebrew/Cellar/portmidi/217_2/include -L /opt/homebrew/Cellar/portmidi/217_2/lib -I/Users/owen/.asdf/installs/erlang/24.1.4/erts-12.1.4/include -fPIC -shared -dynamiclib -undefined dynamic_lookup -o priv/portmidi_devices.so -lportmidi src/portmidi_devices.c src/portmidi_shared.c For now, my app points to the local version of ex-portmidi. There appear to be a few changes required to make the package platform agnostic:
@thbar @lucidstack I'm happy to push a PR, but I'm not sure how to solve the problem aside from hardcoding the flags I need in Makefile. |
Hi @type1fool! Thanks for sharing this ; on my side (also Mac M1), I believe I have it handled in thbar#10. The At some point also I will have to bring back the various commits I did on my fork (master...thbar:master), or transfer ownership so I can publish the packages. |
Nice! I switched to your git version and it just works™️. It would be great to see those changes merged upstream. |
@thbar I'm not sure what to do with this error: I noticed you're using MacOS for your fork, but I don't see any special portmidi steps aside from |
Hi Andrea, as promised after our quick chat on slack, here is the issue I'm experiencing with the latest version of ex-portmidi added to a fresh mix project,
When adding ex-portmidi to a fresh mix project portmidi fails to compile.
Steps to reproduce:
mix new midi_test --sup
mix compile
This results in the following error output:
Elixir version: 1.8.1
Erlang/OTP: 21.0
When doing the exact same as above using version "~> 4.2.0" it works as expected.
Let me know if you need any more input or if you'd like me to try anything else.
The text was updated successfully, but these errors were encountered: