Windows: OpenCV and Qt Creator

Steps to build OpenCV 2.2 with Qt Creator 2.0.1 and MinGW:

1. Install Qt SDK with the C++ compiler option (MinGW). You can download it here.

2. Add “C:<Qt_directory>/mingw/bin” to the system PATH.

3. Download and install CMake (2.8).

4. Download and install OpenCV2.2.

5. Run CMake GUI.

6. Set the source code: “C:\<OpenCV_directory>”

7. Set where to build binaries to: “C:\<build_directory>”. Example: “C:\OpenCV2.2MinGW”

8. Press Configure

9. Let CMake create the new folder.

10. Specify the generator: MinGW Makefiles.

11. Select “Specify Native Compilers” and click Next.

12. For C set: “C:\<Qt_directory>\mingw\bin\gcc.exe”

13. For C++ set: “C:\<Qt_directory>\mingw\bin\g++.exe”

14. Click Finish

15. In the configuration screen type in “DEBUG” (or “RELEASE” if you want to build a release version) for CMAKE_BUILD_TYPE. Check BUILD_EXAMPLES if you want. Check WITH_QT.

16. Click configure again.

17. The configure screen will make you specify the qmake path. It is in the Qt directory: “C:\<Qt_directory>\qt\bin\qmake.exe”

18. Click configure again. Click generate. Close CMake.

19. Go to the command prompt and go to the folder where you built your binaries (command: cd C:\<build_directory>) and type “mingw32-make” and hit enter (this might take some time).

20. Then type “mingw32-make install” and hit enter again.

About these ads

14 comments

  1. [...] Skip navigation « Windows: OpenCV and Qt Creator [...]

  2. Thankyou very much for your tutorial.
    I get an error @ 26% which says “Linking CXX shared Library ..\..\bin\libopencv_core230.dll then it goes on to say “c:/qtsdk/mingw/bin../lib/gcc/mingw32/4.4o/…/…/…/…/mingw32/bin/ld.exe: cannot find -ltbb”

    Can you help me solve this please.
    I’m using :
    -qtSDK_1_1_2
    -cmake_2.8.4
    -openCV 2.3
    -TBB 3.0

    Thanks in advance!

  3. Hi Nick,

    I don’t remember exactly the error I got with mingw, but I had some warnings in cmake:
    Warning: QT_QMAKE_EXECUTABLE reported QT_INSTALL_LIBS as
    Warning: But QtCore couldn’t be found. …

    So I added Qt bin and lib to system path:
    C:\QtSDK\Desktop\Qt\4.7.3\mingw\bin;
    C:\QtSDK\Desktop\Qt\4.7.3\mingw\lib

    Before running cmake again, remove “C:\”

    I hope it will work for you as well

  4. Sorry, remove “C: build_directory”

  5. sebastian · · Reply

    **sorry for my english**

    this tutorial works Whit OpenCV 2.3.1???

    1. haven’t tried this with later versions of OpenCV :)
      but if you do try, it would be nice of you to share your output so that others would know. thanks

    2. Yes it works with OpenCV 2.3.1 too. I’ve rebuilt it from superpack package since it’s mingw prebuild library doesn’t work.

  6. Thanks for the help.

  7. hi i got some error too. there is my error:
    c:/qtsdk/mingw/bin/./lib/gcc/mingw32/4.4.0/../../../mingw32/bin/ld.exe: cannot find -ltbb

    please help..,
    i got qt sdk 1.2.1
    opencv 2.3.1

    thanks..

    1. Hi Ceren,

      This is the same as Nick’s problem. See the previous comments. A guest has suggested a solution, see if it works for you as well. Thanks :)

  8. whiteguts · · Reply

    Thanks for the tutorial.

    I get theses erros :

    CMake Error: CMake was unable to find a build program corresponding to “MinGW Makefiles”. CMAKE_MAKE_PROGRAM is not set. You probably need to select a different build tool.
    CMake Error: CMake was unable to find a build program corresponding to “MinGW Makefiles”. CMAKE_MAKE_PROGRAM is not set. You probably need to select a different build tool.
    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: Could not find cmake module file:C:/OpenCV-2.3.0-Build/CMakeFiles/2.8.10.2/CMakeCCompiler.cmake
    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: Could not find cmake module file:C:/OpenCV-2.3.0-Build/CMakeFiles/2.8.10.2/CMakeCXXCompiler.cmake
    Configuring incomplete, errors occurred!

    That’s what I have in the configuration screen :

    CMAKE_CONFIGURATION_TYPES (value : Debug;Release)
    CMAKE_CXX_FLAGS_RELEASE (value : -O2 -DNDEBUG)
    CMAKE_INSTALL_PREFIX (value : C:/OpenCV23/OpenCV-23-build/install)
    CMAKE_VERBOSE (value : unchecked)

    Qt : 4.8
    OpenCV : 2.3
    CMake : 2.8

    Please help. :(

    1. you probably skkiped or did this wrong

      2. Add “C:/mingw/bin” to the system PATH.

      Make sure /mingw/bin is in system path before running cmake.

  9. We would like to thank you once again for the beautiful ideas you gave Janet when preparing her post-graduate investigate and also, the majority prominently, regarding providing many
    of the ideas in one blog post. If we had been aware of your web-site a year back, we
    may have been rescued from the needless measures we were implementing.
    Thanks to you.

  10. http://google.com · · Reply

    “Windows: OpenCV and Qt Creator Learn, Rant, Discover” ended up being
    a good article and therefore I was indeed extremely content to locate the blog.
    Thanks for your time-Fay

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: