lucidstack / ex-portmidi

Elixir bindings to the portmidi library
MIT License
35 stars 12 forks source link

v5.1.0 fails to compile #7

Closed thbar closed 7 years ago

thbar commented 7 years ago

While trying to test out the timestamp support (see #6), I updated from v5.0.1 to v5.1.0 and got that error:

$ mix deps.get && mix compile
Running dependency resolution
All dependencies up to date
==> portmidi
cc -g -std=c99 -O3 -pedantic -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -I/usr/local/Cellar/erlang/18.3/lib/erlang/erts-7.3/include -fPIC -shared -dynamiclib -undefined dynamic_lookup -o priv/portmidi_in.so -lportmidi src/portmidi_in.c src/portmidi_shared.c
src/portmidi_in.c:34:59: warning: incompatible pointer to integer conversion passing 'void *' to parameter of type 'long' [-Wint-conversion]
  if((result = findDevice(streamAlloc, deviceName, INPUT, NULL)) != pmNoError) {
                                                          ^~~~
/usr/include/sys/_types/_null.h:29:15: note: expanded from macro 'NULL'
#define NULL  __DARWIN_NULL
              ^~~~~~~~~~~~~
/usr/include/sys/_types.h:52:23: note: expanded from macro '__DARWIN_NULL'
#define __DARWIN_NULL ((void *)0)
                      ^~~~~~~~~~~
src/portmidi_in.c:12:79: note: passing argument to parameter 'latency' here
PmError findDevice(PmStream **stream, char *deviceName, DeviceType type, long latency);
                                                                              ^
1 warning generated.
ld: can't open output file for writing: priv/portmidi_in.so, errno=2 for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [priv/portmidi_in.so] Error 1
could not compile dependency :portmidi, "mix compile" failed. You can recompile this dependency with "mix deps.compile portmidi", update it with "mix deps.update portmidi" or clean it with "mix deps.clean portmidi"
==> test
** (Mix) could not run `make`. Do you have make, gcc and libportmidi installed?

This happens with a brand new mix project.

I'm not sure yet what is happening here ; I've been able to clone the repo locally and launch the tests etc, I see warnings but no errors. Maybe the compilation is stopped with a non zero exit-code due to a warning.

lucidstack commented 7 years ago

Hi there, sorry for the long wait! I've just published version 5.1.1, which should hopefully get rid of this issue. I think you compiler is somehow a bit too pedantic and fails with that warning about the NULL incompatibility, so I've replaced it with a simple 0 (that argument is not used anyway for input devices).

Let me know how it goes! 👋

thbar commented 7 years ago

Hi! No need to apologize for the wait - you don't owe anything to anyone :-)

This new version goes a bit further, thanks for the patch !

I then stumble on another issue, which I'll investigate (but I still wanted to provide feedback):

== Compilation error on file lib/portmidi/nifs/devices.ex ==

11:53:40.854 [warn]  The on_load function for module Elixir.PortMidi.Nifs.Devices returned {:error, {:bad_lib, 'Library version (2.11) not compatible (with 2.10).'}}

** (MatchError) no match of right hand side value: {:error, :on_load_failure}
    (stdlib) erl_eval.erl:670: :erl_eval.do_apply/6
zenwerk commented 7 years ago

@thbar Hi. I experienced the same error. That error may be caused by the version of Erlang VM you are using.

if you use Homebrew on Mac, exec brew switch erlang 19.x; brew link --overwrite erlang to make sure use latest Erlang VM.

thbar commented 7 years ago

@zenwerk I switched to 19.3, then cleaned/recompiled, and ultimately it worked. Closing this one. Thanks!