Ask Your Question

opencv 3.0 with contrib installation guide

asked 2015-08-17 07:45:04 -0600

mubb gravatar image

Hi there,

I've tried a few different methods in order to install opencv 3.0 gold WITH the opencv_contrib modules (I would like to use the tracking ones in particular), none of which seem to work.

Can someone provide me a quick installation guide that he/she has successfully tested on a windows machine ?

What doesn't work for me : - using cmake to build opencv with contrib modules (mingw) and developing in codeblocks (weird atomic fetch error) - trying to use cmake to build visual studio 2015 libraries (building issue when opening cmake built projects)

Each time I build in cmake I seem to have to disable IPP, comment out a line in opencvcompikeroptions.cmake following various answers found here or on stack overflow.

Any ideas as to how to start from scratch ? I've tried same unsuccesfull methods on two machines running win7 and win10

Thanks !


edit retag flag offensive close merge delete


in cmake you have to set variables OPENCV_EXTRA_MODULES_PATH to to your path for example opencv_contrib/modules

I haven't got any problem with IPP. But cmake want to load IPP. So if you haven't got an internet link you have to download before and give path after

LBerger gravatar imageLBerger ( 2015-08-17 07:53:12 -0600 )edit

Done that extra modules part with no problems.

Effectively I don't have internet-could disabling IPP be the cause of my issues ?

mubb gravatar imagemubb ( 2015-08-17 07:55:47 -0600 )edit

you can download IPP on another machine using this link. After you have to set variable for IPP path (I don't know variable name)

LBerger gravatar imageLBerger ( 2015-08-17 08:03:40 -0600 )edit

Have you successfully built an opencv library with contrib modules using cmake/mingw without unticking WITH_IPP ?

mubb gravatar imagemubb ( 2015-08-17 08:19:51 -0600 )edit

No I don't use mingw. I use VS 2013.

LBerger gravatar imageLBerger ( 2015-08-17 08:33:43 -0600 )edit

Okay, so could you explain the step by step method to get opencv3 with contrib modules to work in VS? First build with cmake then what ? Thx !

mubb gravatar imagemubb ( 2015-08-17 08:59:38 -0600 )edit

You don't build a project cmake you create your own project to build opencv (opencv.sln) You can use CMake GUI 3.3.0 (with 3.29 is good too). Open cmake GUI select where folder where you clone opencv. select where you want to build (normally same folder) check box advanced and grouped. Click in configure and generate.Normally nothing must be red (or may be some warnings). It's OK when opencv.sln is created.

You can select some options BUILD_EXAMPLES give path to opencv_contrib (in that case you have to disable build_opencv_adas) WITh_opencl with_opengl

Now you can create your own project using cmake

LBerger gravatar imageLBerger ( 2015-08-17 09:33:06 -0600 )edit

Did all that, but when I build project in VS2015 it's giving me plenty of opencv_core alerts and fails to build... Did I miss anything ? I used cmake to configure then generate the opencv project file, specifying where to contrib folder was and other options. What should I look for now ?

mubb gravatar imagemubb ( 2015-08-17 10:02:08 -0600 )edit

I have just try with VS 2015 and cmake 3.3.0 with opencv 3.0 I have got only two errors one in project opencv_perf_core and (sample) disparity_filtering.

What are your errors?

LBerger gravatar imageLBerger ( 2015-08-17 10:22:58 -0600 )edit

@mubb, which gcc version are you using ? that thing might be too old, if it has no atomic_fetch instructions, it won't even build the core opencv libs properly (save the contrib ones)

berak gravatar imageberak ( 2015-08-18 01:23:14 -0600 )edit

2 answers

Sort by » oldest newest most voted

answered 2015-08-19 11:05:34 -0600

LBerger gravatar image

updated 2015-08-19 11:13:12 -0600

I have installed codeblocks-13.12mingw-setup-TDM-GCC-481 on windows 10 with cmake 3.3.0 and opencv 3.0-dev and opencv_contrib. I have disabled modules linedescriptors in contrib.

comment line in 77 datasets/src/util.cpp (// mkdir(path.c_str(), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);) change line in 87 datasets/src/util.cpp ( int n = 0;//scandir(dirName.c_str(), &namelist, NULL, alphasort);;) (it should be better to disable this module) and it works.

I have used this post

there is an existing ticket about this

edit flag offensive delete link more


Will this fix atomic_fetch error ? I think I had already disabled both linedescriptor and dataset modules... I'll give it a try nonetheless !

mubb gravatar imagemubb ( 2015-08-20 03:54:24 -0600 )edit

What were you cmake configuration choices? Did you use 'mingw makefile" or another, like codenlocka mingw that creates a project file for opencblibrary configuration?


mubb gravatar imagemubb ( 2015-08-24 09:38:06 -0600 )edit

CMake generator: MinGW Makefiles

LBerger gravatar imageLBerger ( 2015-08-24 09:49:33 -0600 )edit

answered 2015-09-24 09:22:11 -0600

updated 2015-09-24 11:54:22 -0600

Open CMake, and point it to the OpenCV sources directory.

Create a new folder under OpenCV called my_build.

Point CMake's "Where to build the binaries" field to the my_build folder.

Hit Configure. CMake will ask you about the compiler. If you want the CodeBlocks build, you should specify that it's MinGW for CodeBlocks, because OpenCV 's cmake file will output a CodeBlocks file that will help with compiling. You make need to specify the native compiler to match the compiler used for your project.

Once the Configure process has finished, everything should be in red. This does not indicate an error. CMake needs you to verify the configuration data.

1 - Find the "With" drop-down, and uncheck WITH_IPP (and IPP_A, if it is checked). These only work under Visual Studios. 2 - Under "Build", check BUILD_SHARED_LIBS for dlls, uncheck for .a 3 - Check under the "CMake" tab to make sure CMake hasn't changed any of your compiler options, as it often does. It changed 2 of mine. Check: CMAKE_AR, CMAKE_LINKER, CMAKE_MAKE_PROGRAM, NM, OBJCOPY, OBJDUMP, RANLIB, RC_COMPILER, STRIP

Click "Configure" again.

Any time you click configure, you should check all of the above options because CMake sometimes loses track of your settings. Once you have nothing else in red, and every option is correct, click Generate.

Navigate to the my_build directory under the OpenCV folder. You should see an OpenCV.cbp. Open it in CodeBlocks.

Configure CodeBlocks to use the same compiler that was specified in CMake.


You will most likely encounter 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.

Hit compile. Sit back and wait.

If you are using TDM as the compiler, you'll most likely encounter ANOTHER issue with libstdc++ claiming a whole mess of things are redefined/have multiple definitions. If this happens, go to your my_build directory in Cygwin, and run the following command:

grep -rl 'lstdc' ./ | xargs sed -i 's/lstdc/static-libstdc/g'

The command replaces a bunch of dynamic linking instances with statically linked instances of libstdc.

Hit compile to start compiling from where you left off.


Once the compile is done, in the my_build libraries, you will have a /lib/ with the .a's, and a /bin/ with the dlls

Create a new console project in CodeBlocks, and use the following code:

#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <iostream>

using namespace cv;
using namespace std;

int main( int argc, char** argv )
    if( argc != 2)
     cout <<" Usage: display_image ImageToLoadAndDisplay" << endl;
     return -1;

    Mat image;
    image = imread(argv[1], IMREAD_COLOR); // Read the file

    if(! ) // Check for invalid input
        cout << "Could not open or find the image" << std::endl ;
        return -1;

    namedWindow( "Display window", WINDOW_AUTOSIZE ); // Create a window for display.
    imshow( "Display window", image ); // Show our image inside it.

    waitKey(0); // Wait for a ...
edit flag offensive delete link more



I've been working on this guide for a couple of days now. Currently, I have everything working EXCEPT that I can't figure out how to get the debug versions of the static libraries. I've already posted a question for this.

mikegibson_dajac gravatar imagemikegibson_dajac ( 2015-09-24 09:24:48 -0600 )edit

Unfortunately, this doesn't fix the atomic_fetch errors that i am having while buliding OCV3 with contrib modules on a windows7 computer for codeblocks...

mubb gravatar imagemubb ( 2015-10-14 08:37:00 -0600 )edit

Question Tools

1 follower


Asked: 2015-08-17 07:45:04 -0600

Seen: 10,226 times

Last updated: Sep 24 '15