Closed edwardzhou closed 1 year ago
Hi, I haven't tried compiling it with GCC on macOS. It's recommended to use clang
on macOS at the moment.
However, as a quick workaround, you can set RPATH
options in the environment variable CMAKE_EVISION_OPTIONS
so that the linker can add /usr/local/Cellar/gcc/12.2.0/lib/gcc/12/
to RPATH
.
Oh sorry I missed the clang: error:
part, it seems that cmake is trying to link libquadmath.0.dylib
from brew installed gcc
while using clang
. Perhaps you can try temporarily unlinking gcc? brew unlink gcc
, nuke the _bulid/dev/lib/evision
and try mix compile
again?
the same result, with or without CMAKE_EVISION_OPTIONS.
brew unlink gcc
2. compile both with and without CMAKE_EVISION_OPTIONS
```bash
export CMAKE_EVISION_OPTIONS="-rpath=/usr/local/Cellar/gcc/12.2.0/lib/gcc/12"
mix compile
> same error.
export CMAKE_EVISION_OPTIONS=""
mix compile
> same error.
Okay, I see. Could you please attach a full build log?
The full build log is too large to put in comment. I upload to gist, please find it in below link.
Thanks for providing the build log.
AFAICT, libavcodec, libavformat and libavutil 59.37.100 are the libraries from FFMPEG 5.x, which I still need to test. And the reference to libquadmath.0.dylib
came from these libraries.
I know that since OpenCV 4.7.0, they announced that FFMPEG 5.x is supported, but I'm working on porting opencv_contrib modules at the moment; hence I didn't have enough time to focus on testing compiling this library with FFMPEG 5.x.
I wonder if it would be possible for you to link and use FFMPEG@4 for now? And actually, I'm still actively pushing commits to the main branch as I'm testing modules from opencv_contrib. It might be better to use the code from a released version,
defp deps do
[
{:evision, github: "cocoa-xu/evision", tag: "v0.1.25"}
]
end
I wonder if it would be possible for you to link and use FFMPEG@4 for now? And actually, I'm still actively pushing commits to the main branch as I'm testing modules from opencv_contrib. It might be better to use the code from a released version,
defp deps do [ {:evision, github: "cocoa-xu/evision", tag: "v0.1.25"} ] end
It pass compile with
export CMAKE_OPENCV_OPTIONS="-D WITH_FFMPEG=OFF"
and will fail if WITH_FFMEPG=ON
^
In file included from /Users/edwardzhou/elixir_work/evision_demo/deps/evision/3rd_party/opencv/opencv-4.6.0/modules/videoio/src/cap_ffmpeg.cpp:50:
In file included from /Users/edwardzhou/elixir_work/evision_demo/deps/evision/3rd_party/opencv/opencv-4.6.0/modules/videoio/src/cap_ffmpeg_impl.hpp:81:
/Users/edwardzhou/elixir_work/evision_demo/deps/evision/3rd_party/opencv/opencv-4.6.0/modules/videoio/src/ffmpeg_codecs.hpp:168:7: error: use of undeclared identifier 'CODEC_ID_MPEG4'; did you mean 'AV_CODEC_ID_MPEG4'?
{ AV_CODEC_ID_MPEG4, MKTAG(0x04, 0, 0, 0) }, /* some broken avi use this */
^~~~~~~~~~~~~~~~~
AV_CODEC_ID_MPEG4
/Users/edwardzhou/elixir_work/evision_demo/deps/evision/3rd_party/opencv/opencv-4.6.0/modules/videoio/src/ffmpeg_codecs.hpp:86:27: note: expanded from macro 'AV_CODEC_ID_MPEG4'
#define AV_CODEC_ID_MPEG4 CODEC_ID_MPEG4
^
/usr/local/Cellar/ffmpeg/5.1.2_1/include/libavcodec/codec_id.h:62:5: note: 'AV_CODEC_ID_MPEG4' declared here
AV_CODEC_ID_MPEG4,
^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
1 warning and 20 errors generated.
make[3]: *** [modules/videoio/CMakeFiles/opencv_videoio.dir/src/cap_ffmpeg.cpp.o] Error 1
make[2]: *** [modules/videoio/CMakeFiles/opencv_videoio.dir/all] Error 2
make[2]: *** Waiting for unfinished jobs....
[ 92%] Building CXX object modules/stitching/CMakeFiles/opencv_stitching.dir/src/warpers_cuda.cpp.o
[ 92%] Building CXX object modules/stitching/CMakeFiles/opencv_stitching.dir/opencl_kernels_stitching.cpp.o
[ 92%] Linking CXX shared library ../../lib/libopencv_stitching.dylib
[ 92%] Built target opencv_stitching
make[1]: *** [all] Error 2
make: *** [/Users/edwardzhou/elixir_work/evision_demo/_build/dev/lib/evision/cmake_opencv_4.6.0/modules/python_bindings_generator/headers.txt] Error 2
could not compile dependency :evision, "mix compile" failed. Errors may have been logged above. You can recompile this dependency with "mix deps.compile evision", update it with "mix deps.update evision" or clean it with "mix deps.clean evision"
==> evision_demo
** (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.
Yes, that's what should be expected, as v0.1.25
is based on OpenCV 4.6.0, and I'm working on OpenCV 4.7.0 + opencv_contrib
atm.
Cannot reproduce this on my local Intel Mac. I'll try and see if there are any errors when building it with FFMPEG 5.x on CI.
Cannot reproduce this issue on GitHub CI either. https://github.com/cocoa-xu/evision/actions/runs/3919226992/jobs/6700095748#step:9:676
@edwardzhou Is there by any chance you were using a custom build of FFmpeg 5.x?
@edwardzhou Is there by any chance you were using a custom build of FFmpeg 5.x?
yes. all pass on ffmpeg 5.1.2
$ brew info ffmpeg
==> ffmpeg: stable 5.1.2 (bottled), HEAD
Play, record, convert, and stream audio and video
https://ffmpeg.org/
/usr/local/Cellar/ffmpeg/5.1.2_1 (282 files, 51.9MB) *
Poured from bottle on 2023-01-11 at 18:36:22
From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/ffmpeg.rb
License: GPL-2.0-or-later
==> Dependencies
Build: pkg-config ✔, nasm ✘
Required: aom ✔, aribb24 ✘, dav1d ✔, fontconfig ✔, freetype ✔, frei0r ✔, gnutls ✔, lame ✔, libass ✔, libbluray ✔, librist ✔, libsoxr ✔, libvidstab ✔, libvmaf ✔, libvorbis ✔, libvpx ✔, opencore-amr ✔, openjpeg ✔, opus ✔, rav1e ✔, rubberband ✔, sdl2 ✔, snappy ✔, speex ✔, srt ✔, svt-av1 ✘, tesseract ✔, theora ✔, webp ✘, x264 ✔, x265 ✔, xvid ✔, xz ✔, zeromq ✔, zimg ✔
==> Options
--HEAD
Install HEAD version
==> Analytics
install: 134,981 (30 days), 445,902 (90 days), 1,841,495 (365 days)
install-on-request: 116,986 (30 days), 383,627 (90 days), 1,607,634 (365 days)
build-error: 157 (30 days)
export EVISION_GENERATE_LANG="erlang,elixir"
export OPENCV_VER="4.7.0"
export EVISION_PREFER_PRECOMPILED=false
export CMAKE_OPENCV_OPTIONS="-D WITH_FFMPEG=ON"
export MAKE_BUILD_FLAGS="-j$(nproc)"
cat mix.exs
....
defp deps do
[
....
{:evision, github: "cocoa-xu/evision"}
]
end
mix deps.get
mix compile
...
- 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: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Using PRIV_DIR: /Users/edwardzhou/elixir_work/evision_demo/_build/dev/lib/evision/priv
-- Using ERTS_INCLUDE_DIR: /Users/edwardzhou/.asdf/installs/erlang/25.1.2/erts-13.1.2/include
-- Found OpenCV: /Users/edwardzhou/elixir_work/evision_demo/_build/dev/lib/evision/priv (found version "4.7.0")
-- EVISION_ENABLE_CONTRIB=true
Note: Class Feature2D has more than 1 base class (not supported by Python C extensions)
Bases: cv::Algorithm, cv::class, cv::Feature2D, cv::Algorithm
Only the first base class will be used
Note: Class detail_GraphCutSeamFinder has more than 1 base class (not supported by Python C extensions)
Bases: cv::detail::GraphCutSeamFinderBase, cv::detail::SeamFinder
Only the first base class will be used
-- Successfully generated binding code for: erlang,elixir
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/edwardzhou/elixir_work/evision_demo/_build/dev/lib/evision/cmake_evision
make[1]: warning: -jN forced in submake: disabling jobserver mode.
[ 50%] Building CXX object CMakeFiles/evision.dir/c_src/evision.cpp.o
[100%] Linking CXX shared library evision.so
ld: warning: -undefined dynamic_lookup may not work with chained fixups
[100%] Built target evision
Compiling 433 files (.ex)
Compiling lib/generated/evision.ex (it's taking more than 10s)
Compiling lib/generated/evision_nif.ex (it's taking more than 10s)
Generated evision app
==> evision_demo
Compiling 3 files (.ex)
Generated evision_demo app
Glad it works now. Yet the mystery deepens as the only relevant change I made was to disable the sfm
module from opencv_contrib.
I'll close this issue for now as it appears that everything works as expected with FFmpeg 5.1.2.
Although I still don't know why libquadmath.0.dylib
was required in the initial issue report. If there is more information and that bug can be reproduced, please feel free to reopen this issue, and I'll look into it. :)
MacOS Ventura 13.1 (22C65) Python 3.10.9 (install with asdf) Elixir 1.14.2 (compiled with Erlang/OTP 25)
deps in mix.exs
environment setup
Got following error when mix compile
but libquadmath.0.dylib exists and x86_64 arch.