Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Qt4.8.6 and VS2013: Execution fails in Release Mode
Forum Update on Monday, May 27th 2025

Qt4.8.6 and VS2013: Execution fails in Release Mode

Scheduled Pinned Locked Moved Solved General and Desktop
visual studio
10 Posts 4 Posters 3.5k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • MattSM Offline
    MattSM Offline
    MattS
    wrote on last edited by MattS
    #1

    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.

    1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by
      #2

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

      1 Reply Last reply
      1
      • MattSM Offline
        MattSM Offline
        MattS
        wrote on last edited by MattS
        #3

        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

        1 Reply Last reply
        0
        • mrjjM Offline
          mrjjM Offline
          mrjj
          Lifetime Qt Champion
          wrote on last edited by
          #4

          hi
          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.

          http://www.tripleboot.org/?p=138

          1 Reply Last reply
          1
          • MattSM Offline
            MattSM Offline
            MattS
            wrote on last edited by
            #5

            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.

            mrjjM 1 Reply Last reply
            1
            • MattSM MattS

              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.

              mrjjM Offline
              mrjjM Offline
              mrjj
              Lifetime Qt Champion
              wrote on last edited by
              #6

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

              1 Reply Last reply
              0
              • MattSM Offline
                MattSM Offline
                MattS
                wrote on last edited by MattS
                #7

                @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.

                mrjjM K 2 Replies Last reply
                0
                • MattSM MattS

                  @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.

                  mrjjM Offline
                  mrjjM Offline
                  mrjj
                  Lifetime Qt Champion
                  wrote on last edited by
                  #8

                  @MattS
                  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 :)

                  1 Reply Last reply
                  0
                  • MattSM MattS

                    @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.

                    K Offline
                    K Offline
                    KeithS
                    wrote on last edited by
                    #9

                    @MattS

                    One thing you can try is use dependency walker (www.dependencywalker.com) 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!

                    1 Reply Last reply
                    0
                    • SGaistS Offline
                      SGaistS Offline
                      SGaist
                      Lifetime Qt Champion
                      wrote on last edited by
                      #10

                      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.

                      Interested in AI ? www.idiap.ch
                      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                      1 Reply Last reply
                      0

                      • Login

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • Users
                      • Groups
                      • Search
                      • Get Qt Extensions
                      • Unsolved