Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Solved Qt4.8.6 and VS2013: Execution fails in Release Mode

    General and Desktop
    visual studio
    4
    10
    3143
    Loading More Posts
    • 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.
    • MattS
      MattS last edited by MattS

      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 Reply Quote 0
      • mrjj
        mrjj Lifetime Qt Champion last edited by

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

        1 Reply Last reply Reply Quote 1
        • MattS
          MattS last edited by MattS

          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 Reply Quote 0
          • mrjj
            mrjj Lifetime Qt Champion last edited by

            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 Reply Quote 1
            • MattS
              MattS last edited by

              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.

              mrjj 1 Reply Last reply Reply Quote 1
              • mrjj
                mrjj Lifetime Qt Champion @MattS last edited by

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

                1 Reply Last reply Reply Quote 0
                • MattS
                  MattS last edited by 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.

                  mrjj K 2 Replies Last reply Reply Quote 0
                  • mrjj
                    mrjj Lifetime Qt Champion @MattS last edited by

                    @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 Reply Quote 0
                    • K
                      KeithS @MattS last edited by

                      @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 Reply Quote 0
                      • SGaist
                        SGaist Lifetime Qt Champion last edited by

                        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 Reply Quote 0
                        • First post
                          Last post