2

I am trying to compile OpenCV 3.0 static libraries for MINGW under Windows 7. To do so, I:

  1. downloaded and unpacked OpenCV
  2. downloaded and installed MingW
  3. downloaded and installed CMake

I also added path to the system "Path" variable to the "bin" directories of OpenCV, MinGW and CMake.

After that I:

  1. run cmake-gui

    4.1. configured with source code "opencv/sources"

    4.2. generated makefile

Everything seems to be OK so far, Makefile already exist in the opencv/sources.

Now I want to compile with make:

c:\OpenCV_3_0\opencv\sources>i:\MinGW\msys\1.0\bin\make.exe
Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation. All rights reserved.

And nothing happened. Could anyone help me what can be wrong?

Make version seem to be OK: i:\OpenCV_3_0\opencv\sources>make -v GNU Make 3.81 Copyright (C) 2006 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

This program built for i686-pc-msys

Also g++ seems to be OK:

i:\OpenCV_3_0\opencv\sources>g++ -v
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=i:/mingw/bin/../libexec/gcc/mingw32/4.8.1/lto-wrapper.exe
Target: mingw32
Configured with: ../gcc-4.8.1/configure --prefix=/mingw --host=mingw32 --build=m
ingw32 --without-pic --enable-shared --enable-static --with-gnu-ld --enable-lto
--enable-libssp --disable-multilib --enable-languages=c,c++,fortran,objc,obj-c++
,ada --disable-sjlj-exceptions --with-dwarf2 --disable-win32-registry --enable-l
ibstdcxx-debug --enable-version-specific-runtime-libs --with-gmp=/usr/src/pkg/gm
p-5.1.2-1-mingw32-src/bld --with-mpc=/usr/src/pkg/mpc-1.0.1-1-mingw32-src/bld --
with-mpfr= --with-system-zlib --with-gnu-as --enable-decimal-float=yes --enable-
libgomp --enable-threads --with-libiconv-prefix=/mingw32 --with-libintl-prefix=/
mingw --disable-bootstrap LDFLAGS=-s CFLAGS=-D_USE_32BIT_TIME_T
Thread model: win32
gcc version 4.8.1 (GCC)
1
  • you can try opencv with mingw . You must update the versions numbers. It's from 2012 Commented Oct 20, 2014 at 0:15

1 Answer 1

6

there are 3 relevant folders here:

  • the source tree. leave it untouched (until you absolutely know what you're doing) . don't build into that one, else you can never cleanup properly.
  • the build folder. all cmake / make generated temp files go here. it can be anywhere on your disk, and you may even delete it later (expect ~2gb temp files)
  • the install folder, that's where the final libs/exe/headers/data go

  1. decide, wether or not you want the contrib_repo contents, evt. dl that.
  2. create a build folder, cd into it.
  3. run cmake/cmake-gui from there . if you're using the cmdline, the last arg should be the opencv source folder (where CmakeLists.txt lives)
  4. rinse and repeat, until you're total happy with the cmake output
  5. run: mingw32-make
  6. if there were no errors run: mingw32-make install

  • using mingw is a bit tricky, you will have to explicitly specify your compiler / make tool in the cmake-settings
  • if you add the contrib modules, you might have to exclude some of them (not all build properly atm.)
  • -D BUILD_SHARED_LIBS=OFF for static libs
  • -D CMAKE_INSTALL_PREFIX=your_install_dir // please set that properly.

here's what i finally used: (please don't slavishly copy that..)

cmake -G "MinGW Makefiles" -D CMAKE_CXX_COMPILER="D:\Programme\MinGW\bin\mingw32-g++.exe" -D CMAKE_MAKE_PROGRAM="D:\Programme\MinGW\bin\mingw32-make.exe" -D OPENCV_EXTRA_MODULES_PATH="../../opencv_contrib/modules" -D WITH_IPP=OFF -D WITH_OPENCL=OFF -D BUILD_TIFF=ON -D WITH_TIFF=ON -D BUILD_PNG=ON -D WITH_PNG=ON -D BUILD_ZLIB=ON -D WITH_JASPER=OFF -D WITH_OPENEXR=OFF -D BUILD_OPENEXR=OFF -D BUILD_SHARED_LIBS=OFF -D BUILD_TESTS=OFF -D BUILD_PERF_TESTS=OFF -D BUILD_opencv_apps=OFF -D BUILD_examples=OFF -D BUILD_opencv_datasets=OFF -D BUILD_opencv_line_descriptor=OFF  ..
mingw32-make
mingw32-make install
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.