Mingw64 on Windows11
Python 3.12.12 [GCC 15.2.0 64 bit (AMD64)] on win32
MSYS2 Package ,mingw-w64-x86_64-python-opencv goes very well with no trouble,
However, I was encountered one issue: the import process takes an very long time.
First time import takes over 60 seconds…especially on newer PC (Core Ultra)
So I decided to build “headless version“ as light module
Following is the procedure.
(1)Remove MSYS2 packages for opencv-python
pacman -R mingw-w64-x86_64-python-opencv
(2)Switching venv(named venv-trw)
source venv-trw/bin/activate
(3)Pip Install
pip install opencv-python-headless
#Failed#
(Log with Error Message)
Installing build dependencies … done
Getting requirements to build wheel … done
Installing backend dependencies … done
Preparing metadata (pyproject.toml) … -
Building wheels for collected packages: opencv-python-headless, numpy
Building wheel for opencv-python-headless (pyproject.toml) … error
error: subprocess-exited-with-error
× Building wheel for opencv-python-headless (pyproject.toml) did not run successfully.
│ exit code: 1
╰─> [525 lines of output]
--------------------------------------------------------------------------------
-- Trying ‘Ninja (Visual Studio 17 2022 x64 v144)’ generator
--------------------------------
---------------------------
----------------------
-----------------
------------
-------
--
Not searching for unused variables given on the command line.
CMake Deprecation Warning at CMakeLists.txt:1 (cmake_minimum_required):
Compatibility with CMake < 3.10 will be removed from a future version of
CMake.
Update the VERSION argument value. Or, use the … syntax
to tell CMake that the project requires at least but has been updated
to work with policies introduced by or earlier.
CMake Error at CMakeLists.txt:2 (PROJECT):
Generator
Ninja
does not support platform specification, but platform
x64 was specified.
-- Configuring incomplete, errors occurred!
(Repeated)
“Why not Mingw64 but Visual Studio(Windows)?”
I have tried various methods to resolve this error, but none of them were effective.
specifying pydistutils.cfg
[build]
compiler=mingw32
[build_ext]
compiler=mingw32
(4)Build from Source and pip wheel
Next, I attempted to manually build the source code within the MinGW64 environment,
and I‘m currently stuck at the final build with ninja.
(i)Get Sourcecode from Github
git clone --recursive https://github.com/opencv/opencv-python.git
(ii)Setting Option as Env
export ENABLE_HEADLESS=1 #Headless version
export CMAKE_ARGS=“-DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++”
#Use Mingw64 build tools
(iii)Build it via pip wheel(mingw64) :FAILED
cd ~/opencv-python
pip wheel . —verbose
…
(Error Message
“Ninja does not support platform specification, but platform
x64 was specified.” )
←-I’m quite stuck now.
Any suggestions would be greatly appreciated.