Static-dynamic mismatch after porting to VS2013, using opencv

  • Hi,
    We have an ongoing project developed in QtCreator, with CMake build system, and after a couple of months, we decided to change the environment to Visual Studio, including an upgrade to Qt 5.5 (from 5.3.1). We use opencv, eigen and boost as external dependencies, the OS is win8.1 64, VS is 32bit 2013 version.
    I downloaded the installer "qt-opensource-windows-x86-msvc2013-5.5.0" (x86 because of the VS version) from the site, and the newest version of OpenCV too (3.0). After creating the project in VS (using the latest VS add-on) and setting up the include and lib folders, I get a compile error saying error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MTd_StaticDebug' doesn't match value 'MDd_DynamicDebug'. In the Runtime Library I have MDd, and I only get OpenCV mismatch errors. After changing the runtime to MTd, OpenCV errors disappear but qtmain.lib says the same - but the reverse of course.
    Is there any chance to solve this without building Qt from source? I have read many forums and found out that building from source may help, with static settings. Which is the correct runtime setting for Qt, I mean the installer installs a Qt version that has been built with MTd or MDd runtime?

    Thank you in advance,

  • Moderators

    First of all you don't need 64bit VS (which doesn't exist yet) to compile and run 64 bit apps so I recommend switching to 64 bit builds. It's 2015 after all and 32bit apps should die already to make all our lives easier. You can build 32bit, 64bit and ARM apps in your 32 bit VS.

    As for the Runtime library, when linking to several external libraries like you do, it's less error prone to link to the dynamic version of runtime library (MD for Release and MDd for Debug). Qt already ships its precompiled libraries this way and it's also the default for new VS projects.
    If OpenCV doesn't provide pre-built binaries with that setting I'd say it's gonna be easier (and better) to build OpenCV from source than to build Qt.

  • @Chris-Kawa thank you for your response! I know that there is no 64bit VS, and you are right about the 64 bit builds, I just don't know how to do it :) I managed to get rid of the problem written above by removing qtmain.lib from the lib listing, and VS builds the app succesfully. I just downloaded the 64 bit Qt version and will try it, hope it will be fine with MD and MDd settings.

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