Elixir CRC не будет компилироваться в MAC OS

Мой проект эликсира косвенно использует crc, который имеет NIF. Они не будут компилироваться. Похоже, что связанный не видит библиотеки.

rtp_to_hls ●  rm -rf deps/ _build/ && mix deps.get && mix compile

==> crc
 C      checksum_xor.c
 C      crc_8.c
 C      crc_algorithm.c
 C      crc_model.c
 C      crc_nif.c
 C      crc_resource.c
 C      xnif_slice.c
 LD     crc_nif.so
Undefined symbols for architecture x86_64:
  "_enif_alloc", referenced from:
      _crc_model_load in crc_model.o
      _kh_resize_crc_stubs in crc_model.o
      _kh_resize_crc_models in crc_model.o
      _crc_nif_debug_table_1 in crc_nif.o
  "_enif_alloc_resource", referenced from:
      _crc_resource_create in crc_resource.o
      _crc_resource_clone in crc_resource.o
      _xnif_slice_create in xnif_slice.o
      _xnif_slice_create_x in xnif_slice.o
  "_enif_consume_timeslice", referenced from:
      _xnif_slice_trap in xnif_slice.o
  "_enif_free", referenced from:
      _crc_model_load in crc_model.o
      _crc_model_unload in crc_model.o
      _kh_resize_crc_stubs in crc_model.o
      _kh_resize_crc_models in crc_model.o
      _crc_nif_debug_table_1 in crc_nif.o
  "_enif_get_map_size", referenced from:
      _crc_init in crc_nif.o
      _crc_init_map_extend in crc_nif.o
  "_enif_get_map_value", referenced from:
      _crc_init in crc_nif.o
      _crc_init_map_extend in crc_nif.o
  "_enif_get_resource", referenced from:
      _crc_resource_get in crc_resource.o
      _xnif_slice_trap in xnif_slice.o
  "_enif_get_tuple", referenced from:
      _crc_init_tuple in crc_nif.o
  "_enif_get_uint", referenced from:
      _crc_nif_checksum_xor_1_work in checksum_xor.o
      _crc_nif_checksum_xor_1_done in checksum_xor.o
      _crc_nif_crc_8_2 in crc_8.o
      _crc_nif_crc_8_init_1 in crc_8.o
      _crc_nif_crc_8_update_2 in crc_8.o
      _crc_nif_crc_8_final_1 in crc_8.o
      _crc_nif_crc_8
  rtp_to_hls ●  gcc --version                                     
Configured with: --prefix=/Library/Developer/CommandLineTools/usr --with-gxx-include-dir=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/4.2.1
Apple clang version 11.0.3 (clang-1103.0.32.62)
Target: x86_64-apple-darwin19.5.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin



rtp_to_hls ●  make --version                                     
GNU Make 3.81
Copyright (C) 2006  Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.

This program built for i386-apple-darwin11.3.0
work in crc_8.o ... "_enif_get_ulong", referenced from: _crc_init_tuple in crc_nif.o "_enif_inspect_binary", referenced from: _crc_nif_checksum_xor_1 in checksum_xor.o _crc_nif_checksum_xor_1_work in checksum_xor.o _crc_nif_crc_8_2 in crc_8.o _crc_nif_crc_8_update_2 in crc_8.o _crc_nif_crc_8
  rtp_to_hls ●  gcc --version                                     
Configured with: --prefix=/Library/Developer/CommandLineTools/usr --with-gxx-include-dir=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/4.2.1
Apple clang version 11.0.3 (clang-1103.0.32.62)
Target: x86_64-apple-darwin19.5.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin



rtp_to_hls ●  make --version                                     
GNU Make 3.81
Copyright (C) 2006  Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.

This program built for i386-apple-darwin11.3.0
work in crc_8.o _crc_nif_crc_8_update
  rtp_to_hls ●  gcc --version                                     
Configured with: --prefix=/Library/Developer/CommandLineTools/usr --with-gxx-include-dir=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/4.2.1
Apple clang version 11.0.3 (clang-1103.0.32.62)
Target: x86_64-apple-darwin19.5.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin



rtp_to_hls ●  make --version                                     
GNU Make 3.81
Copyright (C) 2006  Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.

This program built for i386-apple-darwin11.3.0
work in crc_8.o "_enif_inspect_iolist_as_binary", referenced from: _crc_nif_crc_fast_2 in crc_nif.o _crc_nif_crc_fast_update_2 in crc_nif.o _crc_nif_crc_slow_2 in crc_nif.o _crc_nif_crc_slow_update_2 in crc_nif.o _crc_nif_crc_fast
  rtp_to_hls ●  gcc --version                                     
Configured with: --prefix=/Library/Developer/CommandLineTools/usr --with-gxx-include-dir=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/4.2.1
Apple clang version 11.0.3 (clang-1103.0.32.62)
Target: x86_64-apple-darwin19.5.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin



rtp_to_hls ●  make --version                                     
GNU Make 3.81
Copyright (C) 2006  Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.

This program built for i386-apple-darwin11.3.0
work in crc_nif.o _crc_nif_crc_fast_update
  rtp_to_hls ●  gcc --version                                     
Configured with: --prefix=/Library/Developer/CommandLineTools/usr --with-gxx-include-dir=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/4.2.1
Apple clang version 11.0.3 (clang-1103.0.32.62)
Target: x86_64-apple-darwin19.5.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin



rtp_to_hls ●  make --version                                     
GNU Make 3.81
Copyright (C) 2006  Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.

This program built for i386-apple-darwin11.3.0
work in crc_nif.o _crc_nif_crc_slow
  rtp_to_hls ●  gcc --version                                     
Configured with: --prefix=/Library/Developer/CommandLineTools/usr --with-gxx-include-dir=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/4.2.1
Apple clang version 11.0.3 (clang-1103.0.32.62)
Target: x86_64-apple-darwin19.5.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin



rtp_to_hls ●  make --version                                     
GNU Make 3.81
Copyright (C) 2006  Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.

This program built for i386-apple-darwin11.3.0
work in crc_nif.o ... "_enif_is_atom", referenced from: _crc_init in crc_nif.o "_enif_is_map", referenced from: _crc_init in crc_nif.o "_enif_is_ref", referenced from: _crc_init in crc_nif.o "_enif_is_tuple", referenced from: _crc_init in crc_nif.o "_enif_keep_resource", referenced from: _crc_resource_create in crc_resource.o _crc_resource_clone in crc_resource.o "_enif_make_atom", referenced from: _crc_model_load in crc_model.o _crc_model_list in crc_model.o _crc_nif_make_atoms in crc_nif.o "_enif_make_badarg", referenced from: _crc_nif_checksum_xor_1 in checksum_xor.o _crc_nif_checksum_xor_1_done in checksum_xor.o _crc_nif_crc_8_2 in crc_8.o _crc_nif_crc_8_init_1 in crc_8.o _crc_nif_crc_8_update_2 in crc_8.o _crc_nif_crc_8_final_1 in crc_8.o _crc_nif_crc_8
  rtp_to_hls ●  gcc --version                                     
Configured with: --prefix=/Library/Developer/CommandLineTools/usr --with-gxx-include-dir=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/4.2.1
Apple clang version 11.0.3 (clang-1103.0.32.62)
Target: x86_64-apple-darwin19.5.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin



rtp_to_hls ●  make --version                                     
GNU Make 3.81
Copyright (C) 2006  Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.

This program built for i386-apple-darwin11.3.0
done in crc_8.o ... "_enif_make_list_from_array", referenced from: _crc_nif_debug_table_1 in crc_nif.o "_enif_make_map_put", referenced from: _crc_model_list in crc_model.o _crc_nif_crc_info_1 in crc_nif.o "_enif_make_new_binary", referenced from: _crc_model_list in crc_model.o _crc_nif_crc_info_1 in crc_nif.o "_enif_make_new_map", referenced from: _crc_model_list in crc_model.o _crc_nif_crc_info_1 in crc_nif.o "_enif_make_resource", referenced from: _crc_nif_crc_fast_2 in crc_nif.o _crc_nif_crc_fast_init_1 in crc_nif.o _crc_nif_crc_fast_update_2 in crc_nif.o _crc_nif_crc_slow_2 in crc_nif.o _crc_nif_crc_slow_init_1 in crc_nif.o _crc_nif_crc_slow_update_2 in crc_nif.o _xnif_slice_schedule in xnif_slice.o ... "_enif_make_tuple", referenced from: _crc_nif_debug_table_1 in crc_nif.o _crc_init in crc_nif.o _crc_init_map_extend in crc_nif.o "_enif_make_uint", referenced from: _crc_nif_checksum_xor_1 in checksum_xor.o _crc_nif_checksum_xor_1_work in checksum_xor.o _crc_nif_checksum_xor_1_done in checksum_xor.o _crc_nif_crc_8_2 in crc_8.o _crc_nif_crc_8_init_1 in crc_8.o _crc_nif_crc_8_update_2 in crc_8.o _crc_nif_crc_8_final_1 in crc_8.o ... "_enif_make_ulong", referenced from: _crc_nif_debug_table_1 in crc_nif.o _crc_nif_crc_fast_2 in crc_nif.o _crc_nif_crc_fast_final_1 in crc_nif.o _crc_nif_crc_slow_2 in crc_nif.o _crc_nif_crc_slow_final_1 in crc_nif.o _crc_nif_crc_info_1 in crc_nif.o _crc_nif_crc_residue_1 in crc_nif.o ... "_enif_monotonic_time", referenced from: _xnif_slice_trap in xnif_slice.o "_enif_open_resource_type", referenced from: _crc_resource_load in crc_resource.o _crc_resource_upgrade in crc_resource.o _xnif_slice_load in xnif_slice.o _xnif_slice_upgrade in xnif_slice.o "_enif_realloc", referenced from: _kh_resize_crc_stubs in crc_model.o _kh_resize_crc_models in crc_model.o "_enif_release_resource", referenced from: _crc_nif_crc_fast_2 in crc_nif.o _crc_nif_crc_fast_init_1 in crc_nif.o _crc_nif_crc_fast_update_2 in crc_nif.o _crc_nif_crc_slow_2 in crc_nif.o _crc_nif_crc_slow_init_1 in crc_nif.o _crc_nif_crc_slow_update_2 in crc_nif.o _crc_nif_crc_residue_1 in crc_nif.o ... "_enif_schedule_nif", referenced from: _xnif_slice_schedule in xnif_slice.o _xnif_slice_trap in xnif_slice.o ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation) make: *** [/Users/hajtojakub/Projects/membrane-demo/rtp_to_hls/_build/dev/lib/crc/priv/crc_nif.so] Error 1 could not compile dependency :crc, "mix compile" failed. You can recompile this dependency with "mix deps.compile crc", update it with "mix deps.update crc" or clean it with "mix deps.clean crc" ==> membrane_demo_rtp_to_hls ** (Mix) Could not compile with "make" (exit status: 2). You need to have gcc and make installed. Try running the commands "gcc --version" and / or "make --version". If these programs are not installed, you will be prompted to install them.

Я приступил к проверке env:

  rtp_to_hls ●  gcc --version                                     
Configured with: --prefix=/Library/Developer/CommandLineTools/usr --with-gxx-include-dir=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/4.2.1
Apple clang version 11.0.3 (clang-1103.0.32.62)
Target: x86_64-apple-darwin19.5.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin



rtp_to_hls ●  make --version                                     
GNU Make 3.81
Copyright (C) 2006  Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.

This program built for i386-apple-darwin11.3.0

Скорее всего это проблема конфигурации. Я опубликую минимальный воспроизводимый проект, хотя


person Haito    schedule 09.07.2020    source источник
comment
Какую библиотеку вы используете для CRC? Я предполагаю следующее: github.com/TattdCodeMonkey/crc Вы используете последнюю версию? Если вы клонируете репо и запускаете mix do deps.get, compile, это сработает?   -  person mroach    schedule 10.07.2020
comment
Неа. Я сделал чистый, смешал deps.clean несколько раз. Как вы видели в первом посте, я использовал rm -rf deps/ _build/ && mix deps.get && mix compile. Так что выход был со свежими депсами.   -  person Haito    schedule 10.07.2020


Ответы (1)


Вам необходимо установить библиотеки разработки erlang, где это _enif_*** объявляется семейство функций.

В Debian Linux:

  • через Erlang Solutions — предпочтительнее
  • используя репозиторий дистрибутива: sudo apt install erlang-dev

Для MacOS Erlang Solutions предоставляет только старый OTP версии 19.3, я понятия не имею, предоставляет ли brew последний OTP. Если это так, сделайте brew install erlang-r23-dev или подобное. Если это не так, вы, вероятно, в состоянии скомпилировать