Can OpenCV 2.x be compiled with mingw-w64 through cmake?

asked 2013-04-14 15:48:46 -0500

AndyL gravatar image

I am having all sorts of trouble compiling OpenCV 2.4 with mingw-w64 and cmake on 64bit Windows 7. Has anyone else run into this problem?

My toolchain.cmake file looks like:

set(CMAKE_RC_COMPILER C:/mingw64/bin/windres.exe)
set(CMAKE_C_COMPILER C:/mingw64/bin/x86_64-w64-mingw32-gcc.exe)
set(CMAKE_CXX_COMPILER C:/mingw64/bin/x86_64-w64-mingw32-g++.exe)
set(CMAKE_LINKER C:/mingw64/bin/ld.exe)
set(CMAKE_FIND_ROOT_PATH C:/mingw64)
set(CMAKE_AR C:/mingw64/bin/ar.exe)
set(CMAKE_MAKE_PROGRAM C:/mingw64/bin/mingw32-make.exe)

When I click configure I get something like this ( maybe a linker problem?):

The C compiler identification is GNU 4.8.0
Check for working C compiler: C:/mingw64/bin/x86_64-w64-mingw32-gcc.exe
Check for working C compiler: C:/mingw64/bin/x86_64-w64-mingw32-gcc.exe -- broken
CMake Error at C:/Program Files (x86)/CMake 2.8/share/cmake-2.8/Modules/CMakeTestCCompiler.cmake:61 (message):
  The C compiler "C:/mingw64/bin/x86_64-w64-mingw32-gcc.exe" is not able to
  compile a simple test program.

  It fails with the following output:

   Change Dir: C:/OpenCV2x/build_mingw64/CMakeFiles/CMakeTmp

  Run Build Command:C:/mingw64/bin/mingw32-make.exe

  C:/mingw64/bin/mingw32-make.exe -f

  mingw32-make.exe[1]: Entering directory

  "C:\Program Files (x86)\CMake 2.8\bin\cmake.exe" -E cmake_progress_report
  C:\OpenCV2x\build_mingw64\CMakeFiles\CMakeTmp\CMakeFiles 1

  Building C object

  C:\mingw64\bin\x86_64-w64-mingw32-gcc.exe -o
  CMakeFiles\cmTryCompileExec4112305880.dir\testCCompiler.c.obj -c

  Linking C executable cmTryCompileExec4112305880.exe

  "C:\Program Files (x86)\CMake 2.8\bin\cmake.exe" -E cmake_link_script
  CMakeFiles\cmTryCompileExec4112305880.dir\link.txt --verbose=1

  "C:\Program Files (x86)\CMake 2.8\bin\cmake.exe" -E remove -f

  "" cr CMakeFiles\cmTryCompileExec4112305880.dir/objects.a

  Error running link command: The parameter is incorrect

  CMakeFiles\cmTryCompileExec4112305880.dir\build.make:91: recipe for target
  `cmTryCompileExec4112305880.exe' failed

  mingw32-make.exe[1]: *** [cmTryCompileExec4112305880.exe] Error 2

  mingw32-make.exe[1]: Leaving directory

  makefile:116: recipe for target `cmTryCompileExec4112305880/fast' failed

  mingw32-make.exe: *** [cmTryCompileExec4112305880/fast] Error 2

  CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
  CMakeLists.txt:61 (project)

Configuring incomplete, errors occurred!

Other potential confounders: I also have 32bit mingw installed at c:/mingw/ and I have msys installed in c:/mingw/msys/1.0/. When I run cmake I have been selecting "mingw make" as my generator and I have been clicking on the dialog to select a cross-compiler toolchain at which point I specify the about toolchain.cmake file.

Has anyone else compiled OpenCV with mingw-w64 on Windows before?

edit retag flag offensive close merge delete


The answer is yes. I tried answering my own question but must wait two days as per policy. Will post later.

AndyL gravatar imageAndyL ( 2013-04-15 09:28:24 -0500 )edit