cocoa-xu / evision

Evision: An OpenCV-Erlang/Elixir binding
https://evision.app
Apache License 2.0
323 stars 22 forks source link

Error compiling on Elixir 1.15.0/OTP 26.0.1 on M1 Mac with EVISION_PREFER_PRECOMPILED=true #195

Closed kipcole9 closed 1 year ago

kipcole9 commented 1 year ago

Environment

Current Behaviour

After installing Elixir 1.15.0-otp-26 and Erlang 26.0.1 the following compilation error occurs. I have tried:

Not searching for unused variables given on the command line.

-- The C compiler identification is AppleClang 13.1.6.13160021 -- The CXX compiler identification is AppleClang 13.1.6.13160021 -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done -- Check for working C compiler: /Library/Developer/CommandLineTools/usr/bin/cc - skipped -- Detecting C compile features -- Detecting C compile features - done -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Check for working CXX compiler: /Library/Developer/CommandLineTools/usr/bin/c++ - skipped -- Detecting CXX compile features -- Detecting CXX compile features - done -- Using PRIV_DIR: /Users/kip/Development/image/_build/dev/lib/evision/priv -- Using ERTS_INCLUDE_DIR: /Users/kip/.asdf/installs/erlang/26.0.1/erts-14.0.1/include CMake Error at CMakeLists.txt:27 (find_package): Could not find a package configuration file provided by "OpenCV" with any of the following names:

OpenCVConfig.cmake
opencv-config.cmake

Add the installation prefix of "OpenCV" to CMAKE_PREFIX_PATH or set "OpenCV_DIR" to a directory containing one of the above files. If "OpenCV" provides a separate development package or SDK, be sure it has been installed.

-- Configuring incomplete, errors occurred! See also "/Users/kip/Development/image/_build/dev/lib/evision/cmake_evision/CMakeFiles/CMakeOutput.log". See also "/Users/kip/Development/image/_build/dev/lib/evision/cmake_evision/CMakeFiles/CMakeError.log". incomplete build of OpenCV found in '/Users/kip/Development/image/_build/dev/lib/evision/cmake_opencv_4.7.0', please delete that directory and retry make: *** [/Users/kip/Development/image/_build/dev/lib/evision/priv/evision.so] Error 1 could not compile dependency :evision, "mix compile" failed. Errors may have been logged above. You can recompile this dependency with "mix deps.compile evision --force", update it with "mix deps.update evision" or clean it with "mix deps.clean evision"

cocoa-xu commented 1 year ago

Hi @kipcole9, it seems to be an issue related to CMake. Could you please let me know the CMake's version on your machine?

kipcole9 commented 1 year ago

@cocoa-xu :

% cmake --version
cmake version 3.26.4
cocoa-xu commented 1 year ago

It should try to compile it from source because erlang@26 isn't on homebrew yet, so there's no precompiled version for this combination. And mix deps.clean evision && deps.get only cleans the library's deps directory and some predefined paths I guess?

Could you please try to delete this directory '/Users/kip/Development/image/_build/dev/lib/evision/cmake_opencv_4.7.0' and recompile it?

(Also planning to use asdf to install Erlang for macOS GitHub workflows so that I can do precompiled versions for OTP 26 for macOS)

kipcole9 commented 1 year ago

@cocoa-xu I had tried that (since there is a helpful message to do so). Still no success:

% asdf current
elixir          1.15.0-otp-26   /Users/kip/.tool-versions
erlang          26.0.1          /Users/kip/.tool-versions
rust            stable          /Users/kip/.tool-versions

% rm -rf /Users/kip/Development/image/_build/dev/lib/evision/cmake_opencv_4.7.0
% mix deps.clean evision
* Cleaning evision
% export EVISION_PREFER_PRECOMPILED=true
% mix deps.get
Resolving Hex dependencies...
Resolution completed in 0.071s
....
% iex -S mix
warning: Logger.warn/1 is deprecated. Use Logger.warning/2 instead
  /Users/kip/Development/image/deps/evision/mix.exs:272: Mix.Tasks.Compile.EvisionPrecompiled.warning_if_no_cacertfile!/1

==> evision
CMake Warning:
  Ignoring empty string ("") provided on the command line.

Not searching for unused variables given on the command line.

-- The C compiler identification is AppleClang 15.0.0.15000029
-- The CXX compiler identification is AppleClang 15.0.0.15000029
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /Library/Developer/CommandLineTools/usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /Library/Developer/CommandLineTools/usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Using PRIV_DIR: /Users/kip/Development/image/_build/dev/lib/evision/priv
-- Using ERTS_INCLUDE_DIR: /Users/kip/.asdf/installs/erlang/26.0.1/erts-14.0.1/include
CMake Error at CMakeLists.txt:27 (find_package):
  Could not find a package configuration file provided by "OpenCV" with any
  of the following names:

    OpenCVConfig.cmake
    opencv-config.cmake

  Add the installation prefix of "OpenCV" to CMAKE_PREFIX_PATH or set
  "OpenCV_DIR" to a directory containing one of the above files.  If "OpenCV"
  provides a separate development package or SDK, be sure it has been
  installed.

-- Configuring incomplete, errors occurred!
incomplete build of OpenCV found in '/Users/kip/Development/image/_build/dev/lib/evision/cmake_opencv_4.7.0', please delete that directory and retry
make: *** [/Users/kip/Development/image/_build/dev/lib/evision/priv/evision.so] Error 1
could not compile dependency :evision, "mix compile" failed. Errors may have been logged above. You can recompile this dependency with "mix deps.compile evision --force", update it with "mix deps.update evision" or clean it with "mix deps.clean evision"
kipcole9 commented 1 year ago

BTW, no issues compiling from source for me - that's what I'm doing now to avoid the issue with precompiled binaries.

cocoa-xu commented 1 year ago

Hi @kipcole9, this issue should be fixed in PR #197.

The Makefile target that compiles OpenCV was skipped because EVISION_PREFER_PRECOMPILED stays true while there is no such precompiled binary available.

The fix was to override the environment variable EVISION_PREFER_PRECOMPILED in mix.exs so that the corresponding Makefile target is executed.