Problems Building/Compiling OpenCV 3.0
Hello all,
I downloaded OpenCV to my laptop earlier today in hopes of using it. I previously had v2.4.8 on my desktop and the whole 'no more prebuilt binaries for MinGW' has been causing me grief all day.
The whole problem seems to be CMake. I cannot get it to build/generate the binaries properly.
I tried following the instructions from this blog: OpenCV Install on Windows With Code::Blocks and minGW
The whole process falls apart at the CMake section. So I use the CMakeLists.txt in the opencv\sources since there is none in the opencv folder. I first get these errors:
CMake Error at C:/Program Files (x86)/CMake 2.8/share/cmake-2.8/Modules/CMakeMinGWFindMake.cmake:22 (message):
sh.exe was found in your PATH, here:
C:/MinGW/msys/1.0/bin/sh.exe
For MinGW make to work correctly sh.exe must NOT be in your path.
Run cmake from a shell that does not have sh.exe in your PATH.
If you want to use a UNIX shell, then use MSYS Makefiles.
Call Stack (most recent call first):
CMakeLists.txt:88 (project)
CMake Error: Error required internal CMake variable not set, cmake may be not be built correctly.
Missing variable is:
CMAKE_CXX_COMPILER_ENV_VAR
CMake Error: Error required internal CMake variable not set, cmake may be not be built correctly.
Missing variable is:
CMAKE_CXX_COMPILER
CMake Error: Could not find cmake module file: C:/opencv/build_mingw/CMakeFiles/2.8.12.2/CMakeCXXCompiler.cmake
CMake Error: Error required internal CMake variable not set, cmake may be not be built correctly.
Missing variable is:
CMAKE_C_COMPILER_ENV_VAR
CMake Error: Error required internal CMake variable not set, cmake may be not be built correctly.
Missing variable is:
CMAKE_C_COMPILER
CMake Error: Could not find cmake module file: C:/opencv/build_mingw/CMakeFiles/2.8.12.2/CMakeCCompiler.cmake
CMake Error: CMAKE_CXX_COMPILER not set, after EnableLanguage
CMake Error: CMAKE_C_COMPILER not set, after EnableLanguage
Configuring incomplete, errors occurred!
So I click configure and generate anyways, then cd into the build folder and run mingw32-make
and the build process fails at [34%] with the following:
C:\opencv\sources\modules\core\src\system.cpp: In function 'BOOL cv::DllMain(HINSTANCE, DWORD, LPVOID)':
C:\opencv\sources\modules\core\src\system.cpp:1013:13: warning: no previous declaration for 'BOOL cv::DllMain(HINSTANCE, DWORD, LPVOID)' [-Wmissing-declarations]
BOOL WINAPI DllMain(HINSTANCE, DWORD fdwReason, LPVOID lpReserved)
^
[ 34%] Building CXX object modules/core/CMakeFiles/opencv_core.dir/src/tables.cpp.obj
[ 34%] Building CXX object modules/core/CMakeFiles/opencv_core.dir/src/types.cpp.obj
[ 34%] Building CXX object modules/core/CMakeFiles/opencv_core.dir/src/umatrix.cpp.obj
[ 34%] Building CXX object modules/core/CMakeFiles/opencv_core.dir/opencl_kernels_core.cpp.obj
Linking CXX shared library ..\..\bin\libopencv_core300.dll
c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../../mingw32/bin/ld.exe: cannot find -lRunTmChk
collect2.exe: error: ld returned 1 exit status
modules\core\CMakeFiles\opencv_core.dir\build.make:1236: recipe for target 'bin/libopencv_core300.dll' failed
mingw32-make[2]: *** [bin/libopencv_core300.dll] Error 1 ...
you have to do, what cmake tells you, which is:
explicitly set your c and c++ compilers and the make tool used:
-DCMAKE_MAKE_PROGRAM="D:/Programme/MinGW/bin/mingw32-make.exe" -DCMAKE_CXX_COMPILER="D:/Programme/MinGW/bin/mingw32-g++.exe" -DCMAKE_C_COMPILER="D:/Programme/MinGW/bin/mingw32-gcc.exe"
(ofc. your path will differ, but you have to set those vars.)
then, call :
mingw32-make.exe
(or whatever you got, just not plainmake
) to buildSorry for the late reply, but I haven't had time to try this out.
At first I didn't understand where I was supposed to specify the files as you suggested. The command console I suppose.
I guess I forgot to mention I am using the CMake gui as well. I installed the new version now, 3.3. So what I did was when I clicked 'Configure' for the first time, I chose 'CodeBlocks - MinGW Make Files' from the drop down. Next I clicked the 'Specify Native Compilers' radio button then hit 'Next'. There I chose the MinGW compilers for C/C++ and left the Fortran compiler blank. There was no where to specify the Make program.
Clicking 'Finish' started the configuring with no errors. (I also renamed sh.exe to shXXX.exe so it would stop giving me that error 22).
So now that I run
mingw32-make.exe
as you suggested, I get all the way to [38%]. and I get the following:CMakeFiles\Makefile2:4668: recipe for target 'modules/videoio/CMakeFiles/opencv_videoio.dir/all' failed mingw32-make.exe[1]: * [modules/videoio/CMakeFiles/opencv_videoio.dir/all] Error 2 Makefile:148: recipe for target 'all' failed mingw32-make.exe: * [all] Error 2
At this rate, I'll have OpenCV installed and ready to go by Christmas. What to do from here? Is there another straight forward way that I am not seeing?
Thanks again.
I found these instructions that helped me out: OpenCV 3.0 videoio error
So I got to [100%] and ran
mingw32-make.exe install
everything seems golden. I will try an example tomorrow.