SOLVED anybody writing with Qt 5.3 using OpenCV3 on Windows 7 64 bit machine

  • Simple question, but I have been unable to get them to work together.

  • More details needed.

  • Lifetime Qt Champion


    I haven't worked yet with OpenCV 3 but if they didn't changed it too much, the binary package should come with prebuilt libraries for several versions of Visual Studio as well as one for MinGW.

    So you first have to pick one compiler and then you have to link to the correct version of the libraries (generally more than one)

    Anyway, what errors are you currently getting ?

  • THANKS for the response!!

    I finally got CMake ( to configure and generate opencv-3.0.0-alpha for Qt (I have Qt 5.3.2) and I received no Red errors. However, when I tried compiling it with Visual Studio C++ (MSVC2013 64bit) I got over 4,597 errors and 78 warnings!! Most errors look like this:

    " Error 3 error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MTd_StaticDebug' doesn't match value 'MDd_DynamicDebug' in ann_mlp.obj C:\OpenCV300\build\modules\ml\opencv_core300d.lib(alloc.obj) opencv_ml__ "

    I began checking, I found two items that immediately caught my eye. First, When I checked CMAKE, it says (in the ABOUT box) CMake and Using Qt 4.6.2, even though I tried setting it up for 5.3. Second, I believe there might be a problem with the "Property Page" used with msvc2013 and setting Include Path and dependencies.

    Although I have a basic working knowledge of Qt, CMake & C++. I am not that familiar with the MSVC compiler (still learning and reading). I have done simple stuff, but without errors. 4597 errors kind of threw me!!

    Glad to hear any advise you may provide!!!

  • Lifetime Qt Champion

    Looks like you are trying to build a static debug version while using object build for a dynamic debug version.

    You should build different version in different folders. However to start, just build dynamic versions. Using the static Visual Studio runtime is not recommended.

    The cmake gui may have been built with that version of Qt which is not the same as the one your project will use like e.g. Qt Creator is built with one version of Qt and one compiler but it's completely independent of the Qt versions you'll be using to develop your application.

    If you want to check the parameter that will be used to build e.g. OpenCV, run ccmake in the folder where you configured your build.

  • SGaist,
    I really appreciate your help here!!!
    Unfortunately, I'm just not grasping your first sentence. I'm pretty sure I understand what you mean by a static debug version and a dynamic debug version, I just don't understand what is needed to be done to change them.

    I'm apparently still to new to all this to understand relationships between the different Qt's, CMake's, and MSVC. I downloaded the Qt 5.3.2 binaries, and loaded them. I have used the program for a few months and all works fine as far as I know. I downloaded MS Visual Studio 2013 Express binaries from Microsoft and they worked also. Same with CMake. Not sure I understand why they will not set up OpenCV to work with Qt.

  • One other thing...I read your first response again. I picked the MSVC 2013 64 bit compiler. I think I understand the library differences you referred too, e.g. opencv_core249d.lib is for DEBUG and opencv_249.lib is for RELEASE, correct? Is one considered static and the other dynamic, or am I totally out in the woods?

  • Lifetime Qt Champion

    lib files are tricky on windows, they can either be import libraries or static libraries, generally their size is a good indicator of which type they are.

    Microsoft also proposes two possible runtimes: static and dynamic. Now the fun part: you can build a static lib/app that links to the dynamic runtime or a dynamic library/application against the static runtime.

    The thing is, you have to select one or the other runtime and link all your components to the same version. The recommended runtime is the dynamic.


    However, I'm at my wits end trying to simply get OpenCV to work with a short Qt Wiget project. I spent the last week reading the documentation here, QT and OpenCV books, watching Youtube videos...all without luck. I loaded both PRE-COMPILED programs and can not get then to work together. I tried the source programs and had even more problems.

    This seems to be a whole lot more trouble than it's worth! However, as I've never been a quiter, I'll give it one more week.

    Thanks again!

  • Ok, I have gone from 4500+ errors down to 135. Here are the first five. They all are similar. Can't figure these out! Any guidance??

    Error 1 error LNK2019: unresolved external symbol gzputs referenced in function "void __cdecl icvPuts(struct CvFileStorage *,char const *)" (?icvPuts@@YAXPEAUCvFileStorage@@PEBD@Z) D:\AllProgrammingProjs\C++Stuff\MyNewOpenCV\MyNewOpenCV\opencv_core249d.lib(persistence.obj) MyNewOpenCV
    Error 2 error LNK2019: unresolved external symbol gzgets referenced in function "char * __cdecl icvGets(struct CvFileStorage *,char *,int)" (?icvGets@@YAPEADPEAUCvFileStorage@@PEADH@Z) D:\AllProgrammingProjs\C++Stuff\MyNewOpenCV\MyNewOpenCV\opencv_core249d.lib(persistence.obj) MyNewOpenCV
    Error 3 error LNK2019: unresolved external symbol gzrewind referenced in function "void __cdecl icvRewind(struct CvFileStorage *)" (?icvRewind@@YAXPEAUCvFileStorage@@@Z) D:\AllProgrammingProjs\C++Stuff\MyNewOpenCV\MyNewOpenCV\opencv_core249d.lib(persistence.obj) MyNewOpenCV
    Error 4 error LNK2019: unresolved external symbol gzeof referenced in function "int __cdecl icvEof(struct CvFileStorage *)" (?icvEof@@YAHPEAUCvFileStorage@@@Z) D:\AllProgrammingProjs\C++Stuff\MyNewOpenCV\MyNewOpenCV\opencv_core249d.lib(persistence.obj) MyNewOpenCV
    Error 5 error LNK2019: unresolved external symbol gzclose referenced in function "void __cdecl icvCloseFile(struct CvFileStorage *)" (?icvCloseFile@@YAXPEAUCvFileStorage@@@Z) D:\AllProgrammingProjs\C++Stuff\MyNewOpenCV\MyNewOpenCV\opencv_core249d.lib(persistence.obj) MyNewOpenCV

  • This was an error. double tapped the enter key. sorry!

  • Lifetime Qt Champion

    What do you mean by that ?

    The missing symbols comes from zlib

  • I am TOTALLY lost. Please explain!

  • "What do you mean by that?" I assume you mean my comment about..."This was an error. double tapped the enter key. sorry!"... I pushed enter twice and it logged my comment twice. I deleted the comment and left that message./

    Please explain how you think I can fix the errors with your comment...

    "The missing symbols comes from zlib"

    I'm totally lost here!!


  • Lifetime Qt Champion

    Do you have a zlib.lib file in OpenCV somewhere ?

  • Good evening!
    Yes I have zlib.lib in the following OpenCV2.4.9 (which is the one I am now trying to use).


    I have been trying to use the path for the x64\vc12 and have substituted the last folded with \staticlib, \lib & \bin, individually of course. None seemed to correct the errors.

  • Found a minor typo in the PROPERTY PAGE in Visual C++. That caused the coding to NOT find the proper PATH.

    However, I will still keep studying the difference, and proper coding, for Static and Dynamic Libraries!!

    Thanks again for the assistance and help!!


  • Lifetime Qt Champion

    One important point if you want to go static with Qt, you'll need a commercial license.

    The advantage of static linking is that you don't need to deploy dlls with your application but at the cost of the size of the application. You also don't have the choice when updating, you have to rebuild everything.

    The dynamic linking allows you to switch libraries easily if you need e.g. a more recent version of one of your dependencies (the binary compatibility must still be checked, but that's another point)

  • Ah ha! That would probably be the answer to another question I posted...

    Would that be the reason the "Deploy" options in the Build category are grayed out? They turn on with a commercial license purchase?

  • Lifetime Qt Champion

    AFAIK no, licensing itself doesn't matter

  • Well, that's NOT good news! That means I have another problem!!


Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.