Ask Your Question

Is it possible to build OpenCV 3.2.0 libraries using MinGW for a 32bit Windows?

asked 2017-01-14 16:50:59 -0600

kartikeygupta9097 gravatar image

The installer I downloaded from OpenCV's site had only a 'x64' folder. I use an i686 system. I want to build my libraries (don't know how) using GCC 6.2.0. If you could help me, it'd be cool of you. : D

edit retag flag offensive close merge delete



mingw (esp. the 32bit version) might be a bad choice here, they gave up support for that quite a while ago.

berak gravatar imageberak ( 2017-01-15 02:26:49 -0600 )edit

on the other hand, it's just the same as in linux (minus all dependancies)

get cmake, and see, how far you get, then report back, i guess. good luck.

berak gravatar imageberak ( 2017-01-15 04:08:43 -0600 )edit

Here's the steps I followed... 1. Extracted the OpenCV files to "C:/". 2. Used CMake to configure and generate install files in another folder (named it "opencv-mingw"). 3. Went to that folder using CMD,used the "mingw32-make" and "mingw32-make install" commands.

The problem is that there are no libraries in "opencv-mingw/install/x86/lib" path except "opencv_world320.dll"

What do I do?

kartikeygupta9097 gravatar imagekartikeygupta9097 ( 2017-01-15 05:18:04 -0600 )edit

did it build an opencv_world320.a, too ?

there's a BUILD_opencv_world flag in cmake, if you wanted seperate libs instead.

berak gravatar imageberak ( 2017-01-15 06:49:38 -0600 )edit

using mingw64(MSYS2) and cmake without install all libs (.a) are lib and dll in bin

LBerger gravatar imageLBerger ( 2017-01-15 07:28:15 -0600 )edit

@berak So, does it mean that I can use OpenCV on my system?

kartikeygupta9097 gravatar imagekartikeygupta9097 ( 2017-01-15 07:47:08 -0600 )edit

if you have an opencv_world320.a -- yes, you're good to go.

just link against that (and put the opencv_world320.dll on the PATH, so it will be found at runtime)

berak gravatar imageberak ( 2017-01-15 07:50:06 -0600 )edit

I actually rage quit by deleting directory where I installed the files. So, right now, I'm rebuilding them. But I think I remember seeing a "opencv_world320.dll.a". So, in any of my further projects, Do I just link to that library, and that's it?

kartikeygupta9097 gravatar imagekartikeygupta9097 ( 2017-01-15 08:01:45 -0600 )edit

yes. it's like this: if you enabled BUILD_opencv_world in cmake, you'll get one big chunk (opencv_world320), if you disable it, it will build single, seperate libs (opencv_core320, opencv_imgproc320, etc.)

berak gravatar imageberak ( 2017-01-15 08:26:31 -0600 )edit

if you could write a small post, what actually worked for you, we'd have an answer here !

berak gravatar imageberak ( 2017-01-15 09:27:19 -0600 )edit

1 answer

Sort by ยป oldest newest most voted

answered 2017-01-19 08:45:05 -0600

kartikeygupta9097 gravatar image

updated 2018-01-27 07:57:11 -0600

Answering my own question here.

Here are the steps I followed...

  1. Download OpenCV, MinGW, CMake. Install MinGW and CMake.
  2. Run the OpenCV<version>.exe file. It'll ask you for the extraction location (I chose C:)
  3. Then open cmake gui and choose the location "C:/opencv/sources" for source directory ,and choose whatever build (destination) directory you want. (I chose "C:/opencv-mingw")
  4. Configure. Use default native compiler. Choose "MinGW Makefiles" as the compiler.
  5. After hitting "Configure", I made sure that all the options under "BUILD_opencv_..." where checked. As @berak told me, if you want seperate, individual libraries, uncheck "BUILD_opencv_world" option.
  6. Hit "Generate".
  7. Open CMD, and navigate to the build (destination) folder.
  8. Type mingw32-make or mingw-make, whatever does the job.
  9. Let the building take its sweet time.
  10. After the building process is complete, type mingw32-make install or mingw-make install, whatever your CMD understands.
  11. Done.
  12. You'll find your libraries at "<build-directory>/install/x86(or x64)/mingw/bin". Alternatively, you can also find them at "<build-directory>/bin" folder. Includes are present in the "<build-directory>/install/include" path. Set this path as the default include path.

P.S. - If you want to build the supplied example files as well, check the BUILD_EXAMPLES option in step 4.

edit flag offensive delete link more


thanks a lot, very helpful !

berak gravatar imageberak ( 2017-01-19 08:52:25 -0600 )edit


Javier de la Rosa gravatar imageJavier de la Rosa ( 2017-01-19 13:25:42 -0600 )edit

Question Tools

1 follower


Asked: 2017-01-14 16:50:59 -0600

Seen: 14,166 times

Last updated: Jan 27 '18