简体   繁体   中英

Error building opencv with mingw, qt, windows

I tried to build opencv library with mingw for Qt 5.13.0. I have generated makefiles using the options for cmake:

"C:\Program Files (x86)\CMake\bin\cmake.exe" ../sources -G "MinGW Makefiles" -DWITH_QT=ON -DWITH_QT_OPENGL=ON -DBUILD_EXAMLES=ON -DQT_QTCORE_LIBRARY_DEBUG="Qt5Cored.dll" -DQT_QTCORE_LIBRARY_RELEASE="Qt5Core.dll" -DQT_QMAKE_EXECUTABLE="qmake.exe" -DCMAKE_BUILD_TYPE=Release -DENABLE_PRECOMPILED_HEADERS=OFF

When I tried to build all with "mingw32-make" the error occured:

[ 40%] Building RC object modules/core/CMakeFiles/opencv_core.dir/vs_version.rc.obj
gcc: error: long: No such file or directory
C:\Qt\Tools\mingw730_64\bin\windres.exe: preprocessing failed.
mingw32-make[2]: *** [modules\core\CMakeFiles\opencv_core.dir\build.make:1495: modules/core/CMakeFiles/opencv_core.dir/vs_version.rc.obj] Error 1
mingw32-make[2]: *** Waiting for unfinished jobs....
mingw32-make[1]: *** [CMakeFiles\Makefile2:1889: modules/core/CMakeFiles/opencv_core.dir/all] Error 2
mingw32-make: *** [Makefile:182: all] Error 2

Versions: CMake - 3.17.2, Qt - 5.13.0, opencv - 4.3.0 How do I solve the problem?

Solution: You need to open "modules/core/CMakeFiles/opencv_core.dir/flag.make" and replace "RC_DEFINES=..." with "RC_DEFINES = -DCVAPI_EXPORTS -D_USE_MATH_DEFINES -D_WIN32_WINNT=0x0601 -D__OPENCV_BUILD=1 -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM