Add Windows build helper
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1,4 +1,5 @@
|
|||||||
build/
|
build/
|
||||||
|
build-windows/
|
||||||
cmake-build-*/
|
cmake-build-*/
|
||||||
.qt/
|
.qt/
|
||||||
.qtc/
|
.qtc/
|
||||||
|
|||||||
Binary file not shown.
42
build_windows.bat
Normal file
42
build_windows.bat
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
@echo off
|
||||||
|
setlocal
|
||||||
|
|
||||||
|
rem Usage:
|
||||||
|
rem build_windows.bat C:\Qt\6.6.0\mingw_64 C:\opencv\build
|
||||||
|
rem build_windows.bat C:\Qt\6.6.0\msvc2019_64 C:\opencv\build\x64\vc16\lib "Visual Studio 17 2022"
|
||||||
|
|
||||||
|
if "%~1"=="" (
|
||||||
|
echo Usage: %~nx0 ^<QtDir^> ^<OpenCV_DIR^> [CMakeGenerator]
|
||||||
|
echo Example MinGW: %~nx0 C:\Qt\6.6.0\mingw_64 C:\opencv\build "MinGW Makefiles"
|
||||||
|
echo Example MSVC : %~nx0 C:\Qt\6.6.0\msvc2019_64 C:\opencv\build\x64\vc16\lib "Visual Studio 17 2022"
|
||||||
|
exit /b 1
|
||||||
|
)
|
||||||
|
|
||||||
|
if "%~2"=="" (
|
||||||
|
echo Missing OpenCV_DIR.
|
||||||
|
exit /b 1
|
||||||
|
)
|
||||||
|
|
||||||
|
set QT_DIR=%~1
|
||||||
|
set OPENCV_DIR=%~2
|
||||||
|
set GENERATOR=%~3
|
||||||
|
|
||||||
|
if "%GENERATOR%"=="" (
|
||||||
|
set GENERATOR=MinGW Makefiles
|
||||||
|
)
|
||||||
|
|
||||||
|
if not exist build-windows (
|
||||||
|
mkdir build-windows
|
||||||
|
)
|
||||||
|
|
||||||
|
cmake -S . -B build-windows -G "%GENERATOR%" -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH="%QT_DIR%" -DOpenCV_DIR="%OPENCV_DIR%"
|
||||||
|
if errorlevel 1 exit /b %errorlevel%
|
||||||
|
|
||||||
|
cmake --build build-windows --config Release
|
||||||
|
if errorlevel 1 exit /b %errorlevel%
|
||||||
|
|
||||||
|
echo.
|
||||||
|
echo Build finished.
|
||||||
|
echo If the exe cannot start because DLLs are missing, run:
|
||||||
|
echo "%QT_DIR%\bin\windeployqt.exe" build-windows\QtOpenCVImageTool.exe
|
||||||
|
echo Then copy OpenCV runtime DLLs to the exe directory.
|
||||||
12
readme.md
12
readme.md
@@ -47,6 +47,18 @@ OpenCV_DIR=C:/opencv/build/x64/vc16/lib
|
|||||||
|
|
||||||
### 命令行构建示例
|
### 命令行构建示例
|
||||||
|
|
||||||
|
也可以直接使用项目提供的 `build_windows.bat`:
|
||||||
|
|
||||||
|
```bat
|
||||||
|
build_windows.bat C:\Qt\6.6.0\mingw_64 C:\opencv\build "MinGW Makefiles"
|
||||||
|
```
|
||||||
|
|
||||||
|
或 MSVC:
|
||||||
|
|
||||||
|
```bat
|
||||||
|
build_windows.bat C:\Qt\6.6.0\msvc2019_64 C:\opencv\build\x64\vc16\lib "Visual Studio 17 2022"
|
||||||
|
```
|
||||||
|
|
||||||
MinGW 示例:
|
MinGW 示例:
|
||||||
|
|
||||||
```bat
|
```bat
|
||||||
|
|||||||
Reference in New Issue
Block a user