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. Debugging my C++ application
Forum Updated to NodeBB v4.3 + New Features

Debugging my C++ application

Scheduled Pinned Locked Moved Solved General and Desktop
13 Posts 5 Posters 2.9k Views 3 Watching
  • 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.
  • V Offline
    V Offline
    vlada
    wrote on last edited by
    #1

    Hi,

    I'd like to ask you for help. Today I returned to my music player application after some time and wanted to add some features. But when I wanted to scan music files it always crashed. I reverted all the changes I made and it still crashes.

    The only message I get in the console is that the program finished unexpectedly. I tried to print out some debug messages to find out where exactly it crashes. I narrowed it down to this line.:

    TagLib::FileRef fileRef(reinterpret_cast<const wchar_t *>(fileName.utf16()), true);
    

    This is the line where I create a fileRef instance using the famous taglib library. This code has worked for years. If my application couldn't locate the .dll file, I think it would crash immediately. Not when trying to use it, right?

    The last working binary version I have was compiled using Qt 5.6 , now I upgraded to Qt 5.7. Could there be a problem with compatibility?

    How could I get some more information about the crash? I have no experience with debugging C++ applications. Until now I was always able to find the problem using qDebug() messages. I'm more familiar with Python which always gives me a helpful error message and tells me what went wrong and where. But my C++ program just crashes when calling the command mentioned above.

    This code runs in a background thread, I don't know if it is important.

    1 Reply Last reply
    0
    • VRoninV Offline
      VRoninV Offline
      VRonin
      wrote on last edited by
      #2

      try using TagLib::FileRef fileRef(fileName.toUtf8().constData(), true);

      "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
      ~Napoleon Bonaparte

      On a crusade to banish setIndexWidget() from the holy land of Qt

      1 Reply Last reply
      1
      • V Offline
        V Offline
        vlada
        wrote on last edited by
        #3

        Unfortunately this won't even compile. I now have an idea what might be the problem. I compiled the taglib.dll some time ago. So maybe it is now incompatible with Qt 5.7 built by newer GCC.

        So I tried to compile TagLib using the MinGW binary which comes with Qt. I recompiled the library and replaced the old one with this. Now the application won't even start and right crashes. Again without any useful information about the crash.

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

          Hi,

          Are you sure that the TagLib .dll can be found when your application starts ?

          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
          • V Offline
            V Offline
            vlada
            wrote on last edited by
            #5

            Yes, the library can be found. I think I would get an error about it and the application would not even start.

            This is what I discovered so far:

            1. Qt 5.6 and TagLib compiled with GCC 4.9 - no problems
            2. Qt 5.7 and TagLib compiled with GCC 4.9 - random crashes when using the library
            3. Qt 5.7 and TagLib compiled with GCC 5.3 - immediate crash

            The .dll files are in the same place, nothing is different, only the Qt version and GCC version used to compile TagLib. Is it possible that TagLib is not compatible with GCC 5.x? This is probably not the right place to ask this question.

            But my original problem seems to be case by the incompatibility of GCC 4.9 compiled library with GCC 5.3 compiled Qt. And it can not be solved by recompiling the library with GCC 5.3. So for now I reverted back to Qt 5.6 where everything works as expected.

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

              Did you enable C++11 when building TagLib for Qt 5.7 ?

              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
              • V Offline
                V Offline
                vlada
                wrote on last edited by
                #7

                No, I did not. However I don't know if it was enabled or not. I used CMake-gui and then mingw32-make from command line. How can i enable or disable C++ 11 in this toolchain?

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

                  See here for how to enable c++11 with cmake

                  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
                  • V Offline
                    V Offline
                    vlada
                    wrote on last edited by
                    #9

                    I tried to enable C++11 when compiling TagLib but it still crashes with Qt 5.7 right after program start.

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

                      Can you run a simple application with only TagLib and not Qt code involved ?

                      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
                      • K Offline
                        K Offline
                        KeithS
                        wrote on last edited by
                        #11

                        So have you tried running it under a debugger ?

                        1 Reply Last reply
                        0
                        • V Offline
                          V Offline
                          vlada
                          wrote on last edited by vlada
                          #12

                          @SGaist Thank you for the tip. It helped me to solve the crash. The TagLib source contains also some examples so I built them too. When trying to run it, it complained about missing zlib1.dll. And that was also the problem in QtCreator. I compiled the LagLib library with ZLib support but I didn't copy the zlib1.dll to the build directory. Now with TagLib compiled using GCC 5.3 with C++ 11 enabled, my application works fine also with Qt 5.7.

                          @KeithS No, I did not. That was my original question, how should I use a debugger so I don't have to use my usual try-error approach. This problem is now solved but I would still appreciate some information source/guide where I could study how to use it.

                          kshegunovK 1 Reply Last reply
                          0
                          • V vlada

                            @SGaist Thank you for the tip. It helped me to solve the crash. The TagLib source contains also some examples so I built them too. When trying to run it, it complained about missing zlib1.dll. And that was also the problem in QtCreator. I compiled the LagLib library with ZLib support but I didn't copy the zlib1.dll to the build directory. Now with TagLib compiled using GCC 5.3 with C++ 11 enabled, my application works fine also with Qt 5.7.

                            @KeithS No, I did not. That was my original question, how should I use a debugger so I don't have to use my usual try-error approach. This problem is now solved but I would still appreciate some information source/guide where I could study how to use it.

                            kshegunovK Offline
                            kshegunovK Offline
                            kshegunov
                            Moderators
                            wrote on last edited by kshegunov
                            #13

                            @vlada

                            Try this one. Also this video might be helpful.

                            Read and abide by the 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