Important: Please read the Qt Code of Conduct -

Qt4.8.6 and VS2013: Execution fails in Release Mode

  • Hi everyone,

    I want to use Qt 4.8.6 in a VS2013 project (unfortunately using Qt 5 is not an option). To do so I followed this tutorial and applied the fixes proposed in this Stackoverflow question.

    So I set two environment variables: QTDIR=C:\Qt4.8.6\ and QMAKESPEC=win32-msvc2013 (I changed msvc2012 as proposed in the tutorial to msvc2013). Then I used the VS2013 x86 Native Tools Command Prompt to compile the source using jom. All of this was successful.

    When adding Qt to my VS2013 project everything works fine in Debug mode. But in release mode I get weird errors at very basic Qt calls. For instance this tiny program fails at the toStdString() call with a heap error in void __cdecl _free_base at FreeHeap:

    int main(int argc, char *argv[])
        std::string s = "thisisalongstring";
        QString str = QString::fromStdString(s);
        std::string s2 = str.toStdString();
        return 0;

    I tried to recompile the source but that didn't work. Have I overlooked something when compiling? Can there be something wrong with my project properties? I really have no idea what I didn't wrong and how to fix it. Thanks for your help.

    Note: I posted a similar question to stackoverflow (see this) but I thought maybe this forum is more fitting.

  • Lifetime Qt Champion

    hi and welcome
    Are you 1000% sure there is not any other Qt installed on your machine?

  • Hi,
    thanks for your response. No, quite the contrary. There are other Qt installed on my machine (Qt5 that I need for another project and Qt4.8.1 for VS2008). But does that affect my VS configuration where I explicitly reference Qt4.8.6 for both the bin and the libs folder? Thanks

  • Lifetime Qt Champion

    The reason Im asking is that such strange cases, I have seen when there is mis-match between
    what qt is compiled with and what the app is compiled with. DLLS version / compiler versions.
    If you have a clean pc, you could take the release version and make a deply folder for it and see if it runs on this clean pc.
    Just for test.

  • Hi,
    it looks like you were right. I copied QtCore.dll and QtGui.dll from the Qt directory to the output directory of my sample project and now it did work. Hopefully this will work for the larger project as well.
    Thanks a lot for now. I'll upvote and mark the question as solved as soon as I've validated that.

  • Lifetime Qt Champion

    hi, its the normal deployment
    way so its very likely it will work for the larger project too :)

  • @mrjj
    jep. That did work. Just out of curiosity: I've set the environment variable QTDIR to the correct Qt folder, I added said Qt folder in the VS project properties pointing to exactly those libs in C:\Qt\libs...that didn't work. Then I copied the two libs from C:\Qt\libs to my project directory and it did work. Which dlls were used by VS in the first case? Why not those I pointed to in the project properties? Thanks for the help! That's a great community. Hope I can contribute in the future.

  • Lifetime Qt Champion

    Im not really sure why the QTDir didnt work.
    Normally this happens if people add it to PATH,
    but you seems to have done 100% correctly.
    Im not into/using VS so maybe its a VS thing I dont know about :)

    Yes its a great community and all help is welcome :)

  • @MattS

    One thing you can try is use dependency walker ( to show the libs your app is using - it shows the full path names so you can quickly see if it's picking up the wrong ones.

    Windows uses the following search paths to locate dll's according to Microsoft:

    1. The directory where the executable module for the current process is located.
    2. The current directory.
    3. The Windows system directory. The GetSystemDirectory function retrieves the path of this directory.
    4. The Windows directory. The GetWindowsDirectory function retrieves the path of this directory.
    5. The directories listed in the PATH environment variable.

    Hope that helps!

  • Lifetime Qt Champion

    Hi and welcome to devnet,

    Out of curiosity, are you using Qt Creator or Visual Studio ?

    On a side note, there's Qt 4.8.7 that is available.

Log in to reply