I'm trying to build OpenCV 4.5.5 on a mac mini m1 as follows
- installed openjdk 17
- created folder ~/build_opencv in user home and cd to it
- from this folder call
cmake -DCMAKE_SYSTEM_PROCESSOR=arm64 \
-DCMAKE_OSX_ARCHITECTURES=arm64 \
-DWITH_OPENJPEG=OFF \
-DWITH_IPP=OFF \
-D CMAKE_BUILD_TYPE=RELEASE \
-D CMAKE_INSTALL_PREFIX=/usr/local/opencv \
-D JAVA_INCLUDE_PATH=$JAVA_HOME/include \
-D JAVA_AWT_LIBRARY=$JAVA_HOME/jre/lib/amd64/libawt.so \
-D JAVA_JVM_LIBRARY=$JAVA_HOME/jre/lib/arm/server/libjvm.so \
-D BUILD_opencv_python2=OFF \
-D BUILD_opencv_java=ON \
-D INSTALL_PYTHON_EXAMPLES=OFF \
-D INSTALL_C_EXAMPLES=OFF \
-D OPENCV_ENABLE_NONFREE=OFF \
-D BUILD_EXAMPLES=ON ../opencv-4.5.5
- call
make -j7
Got a lot of warnings like
/Users/testuser/opencv-4.5.5/3rdparty/libpng/pngpriv.h:606:29: note: expanded from macro 'png_isaligned'
(((type)((const char*)ptr-(const char*)0) & \
^~~~~~~~~~~~~~~
/Users/testuser/opencv-4.5.5/3rdparty/libpng/pngrutil.c:3563:23: warning: performing pointer subtraction with a null pointer has undefined behavior [-Wnull-pointer-subtraction]
png_isaligned(sp, png_uint_32) &&
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/testuser/opencv-4.5.5/3rdparty/libpng/pngpriv.h:606:29: note: expanded from macro 'png_isaligned'
(((type)((const char*)ptr-(const char*)0) & \
^~~~~~~~~~~~~~~
/Users/testuser/opencv-4.5.5/3rdparty/libpng/pngrutil.c:4622:34: warning: performing pointer subtraction with a null pointer has undefined behavior [-Wnull-pointer-subtraction]
int extra = (int)((temp - (png_bytep)0) & 0x0f);
^ ~~~~~~~~~~~~
/Users/user/opencv-4.5.5/3rdparty/libpng/pngrutil.c:4626:30: warning: performing pointer subtraction with a null pointer has undefined behavior [-Wnull-pointer-subtraction]
extra = (int)((temp - (png_bytep)0) & 0x0f);
and final message
[ 71%] Building CXX object modules/gapi/CMakeFiles/opencv_gapi.dir/src/backends/python/gpythonbackend.cpp.o
[ 71%] Building CXX object modules/gapi/CMakeFiles/opencv_gapi.dir/src/utils/itt.cpp.o
[ 71%] Linking CXX shared library ../../lib/libopencv_gapi.dylib
[ 71%] Built target opencv_gapi
make: *** [all] Error 2
Also tried openjdk 15 and 18 but led to same result.
Any ideas to fix this would be appreciated.