Ask Your Question
0

Problems Building/Compiling OpenCV 3.0

asked 2015-06-11 01:14:12 -0600

Ermo gravatar image

updated 2015-06-11 02:05:05 -0600

berak gravatar image

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 ...
(more)
edit retag flag offensive close merge delete

Comments

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 plain make) to build

berak gravatar imageberak ( 2015-06-11 01:18:33 -0600 )edit

Sorry 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).

Ermo gravatar imageErmo ( 2015-06-16 00:52:08 -0600 )edit

So now that I run mingw32-make.exe as you suggested, I get all the way to [38%]. and I get the following:

[ 38%] Building CXX object modules/videoio/CMakeFiles/opencv_videoio.dir/src/cap_dshow.cpp.obj
C:\opencv\sources\modules\videoio\src\cap_dshow.cpp:122:11: error: 'struct IEnumPIDMap' has virtual functions and accessible non-virtual destructor [-Werror=non-virtual-dtor]
 interface IEnumPIDMap : public IUnknown
           ^
C:\opencv\sources\modules\videoio\src\cap_dshow.cpp:139:11: error: 'struct IMPEG2PIDMap' has virtual functions and accessible non-virtual destructor [-Werror=non-virtual-dtor]
 interface IMPEG2PIDMap : public IUnknown
           ^
Ermo gravatar imageErmo ( 2015-06-16 00:55:14 -0600 )edit

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.

Ermo gravatar imageErmo ( 2015-06-16 01:00:58 -0600 )edit
1

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.

Ermo gravatar imageErmo ( 2015-06-16 02:25:23 -0600 )edit

1 answer

Sort by » oldest newest most voted
0

answered 2015-09-24 09:31:10 -0600

Adding this for future people browsing the question:

4 errors in 'opencv/sources/modules/videoio/src/cap_dshow.cpp' pertaining to

ISampleGrabberCB, ISampleGrabber, IEnumPIDMap, and IMPEG2PIDMap.

Each of these interfaces needs a virtual destructor added to them (for example, in IEnumPIDMap, add virtual ~IEnumPIDMap(){} ). Adding these fixes the issues.

Conversely, I have noticed that there has been a fix for this MinGW problem submitted, and if you pull the latest revision from git, this problem should clear up.

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2015-06-11 01:14:12 -0600

Seen: 6,207 times

Last updated: Sep 24 '15