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. OpenCV 4.1.1 Imread() & Imwrite() Crashes Program ?
QtWS25 Last Chance

OpenCV 4.1.1 Imread() & Imwrite() Crashes Program ?

Scheduled Pinned Locked Moved Solved General and Desktop
opencvimreadimwrite
23 Posts 5 Posters 5.2k 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.
  • S Offline
    S Offline
    SGaist
    Lifetime Qt Champion
    wrote on 14 Aug 2019, 18:52 last edited by
    #2

    Hi,

    "SamplePath.tiff" is a relative path. Is that file in the same folder as your application ?

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

    R 1 Reply Last reply 14 Aug 2019, 18:58
    0
    • S SGaist
      14 Aug 2019, 18:52

      Hi,

      "SamplePath.tiff" is a relative path. Is that file in the same folder as your application ?

      R Offline
      R Offline
      R-P-H
      wrote on 14 Aug 2019, 18:58 last edited by
      #3

      @sgaist said in OpenCV 4.1.1 Imread() & Imwrite() Crashes Program ?:

      Hi,

      "SamplePath.tiff" is a relative path. Is that file in the same folder as your application ?

      Yes. The program doesn't even open though. And it does the same for imwrite(). So I doubt the path is the problem...

      1 Reply Last reply
      0
      • S Offline
        S Offline
        SGaist
        Lifetime Qt Champion
        wrote on 14 Aug 2019, 18:59 last edited by
        #4

        Did you also copy the OpenCV dlls in the same folder as your executable ?

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

        R 1 Reply Last reply 14 Aug 2019, 19:06
        0
        • S SGaist
          14 Aug 2019, 18:59

          Did you also copy the OpenCV dlls in the same folder as your executable ?

          R Offline
          R Offline
          R-P-H
          wrote on 14 Aug 2019, 19:06 last edited by
          #5

          @sgaist said in OpenCV 4.1.1 Imread() & Imwrite() Crashes Program ?:

          Did you also copy the OpenCV dlls in the same folder as your executable ?

          No, the path to the DLLs is in my systems environment path.

          1 Reply Last reply
          0
          • S Offline
            S Offline
            SGaist
            Lifetime Qt Champion
            wrote on 14 Aug 2019, 19:09 last edited by
            #6

            Then you should use a tool like Dependency Walker to check whether you have dependencies not found.

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

            R 1 Reply Last reply 14 Aug 2019, 19:12
            0
            • S SGaist
              14 Aug 2019, 19:09

              Then you should use a tool like Dependency Walker to check whether you have dependencies not found.

              R Offline
              R Offline
              R-P-H
              wrote on 14 Aug 2019, 19:12 last edited by
              #7

              @sgaist said in OpenCV 4.1.1 Imread() & Imwrite() Crashes Program ?:

              Then you should use a tool like Dependency Walker to check whether you have dependencies not found.

              Ok thanks, I'll give it a try...

              R 1 Reply Last reply 19 Aug 2019, 09:22
              0
              • R R-P-H
                14 Aug 2019, 19:12

                @sgaist said in OpenCV 4.1.1 Imread() & Imwrite() Crashes Program ?:

                Then you should use a tool like Dependency Walker to check whether you have dependencies not found.

                Ok thanks, I'll give it a try...

                R Offline
                R Offline
                R-P-H
                wrote on 19 Aug 2019, 09:22 last edited by
                #8

                @r-p-h said in OpenCV 4.1.1 Imread() & Imwrite() Crashes Program ?:

                @sgaist said in OpenCV 4.1.1 Imread() & Imwrite() Crashes Program ?:

                Then you should use a tool like Dependency Walker to check whether you have dependencies not found.

                Ok thanks, I'll give it a try...

                Hi, dependency walker did not help. It listed some missing dependencies however they have nothing to do with OpenCV and they are still shown as missing even when the program runs fine (when I comment out the imread() function)...

                1 Reply Last reply
                0
                • S Offline
                  S Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on 19 Aug 2019, 18:53 last edited by
                  #9

                  Did you try to start your application with the debugger ?
                  What stack trace do you get ?

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

                  R 1 Reply Last reply 21 Aug 2019, 16:46
                  1
                  • R R-P-H
                    14 Aug 2019, 13:48

                    Hi,

                    I have built OPENCV v4.1.1 from source for Qt. I have linked the necessary libraries and added the include path in the .pro file as follows:

                    INCLUDEPATH += "C:\opencv4-build-x64\install\include"
                    
                    LIBS += -L"C:\opencv4-build-x64\install\x64\mingw\bin" -lopencv_core411 \
                    -lopencv_highgui411 \
                    -lopencv_imgproc411 \
                    -lopencv_imgcodecs411
                    

                    The libraries are .dll files. Now in my source code, I have something like this:

                    #include <opencv2/core/core.hpp>
                    #include <opencv2/highgui/highgui.hpp>
                    #include <opencv2/imgproc/imgproc.hpp>
                    #include <opencv2/imgcodecs/imgcodecs.hpp>
                    
                    int main(){
                    
                    Mat img = imread("SamplePath.tiff", IMREAD_GRAYSCALE);
                    
                    }
                    

                    The program builds fine but when I try to run it, it crashes immediately. If I comment out all the imread() and imwrite() functions, then it runs perfectly.

                    Any ideas ? Thanks.

                    J Offline
                    J Offline
                    JKSH
                    Moderators
                    wrote on 19 Aug 2019, 22:15 last edited by
                    #10

                    @r-p-h said in OpenCV 4.1.1 Imread() & Imwrite() Crashes Program ?:

                    LIBS += -L"C:\opencv4-build-x64\install\x64\mingw\bin" -lopencv_core411
                    -lopencv_highgui411
                    -lopencv_imgproc411
                    -lopencv_imgcodecs411

                    You are linking to the Release DLLs. Are you building your app in Release mode or Debug mode? (A Debug mode app requires Debug DLLs, like opencv_core411d.dll)

                    Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

                    1 Reply Last reply
                    2
                    • J Offline
                      J Offline
                      jhoney
                      Banned
                      wrote on 20 Aug 2019, 11:01 last edited by jhoney
                      #11
                      This post is deleted!
                      1 Reply Last reply
                      0
                      • S SGaist
                        19 Aug 2019, 18:53

                        Did you try to start your application with the debugger ?
                        What stack trace do you get ?

                        R Offline
                        R Offline
                        R-P-H
                        wrote on 21 Aug 2019, 16:46 last edited by JKSH
                        #12

                        @sgaist said in OpenCV 4.1.1 Imread() & Imwrite() Crashes Program ?:

                        Did you try to start your application with the debugger ?
                        What stack trace do you get ?

                        I did, the debugger just ends immediately with no output that I can see.

                        @jksh said in OpenCV 4.1.1 Imread() & Imwrite() Crashes Program ?:

                        @r-p-h said in OpenCV 4.1.1 Imread() & Imwrite() Crashes Program ?:

                        LIBS += -L"C:\opencv4-build-x64\install\x64\mingw\bin" -lopencv_core411
                        -lopencv_highgui411
                        -lopencv_imgproc411
                        -lopencv_imgcodecs411

                        You are linking to the Release DLLs. Are you building your app in Release mode or Debug mode? (A Debug mode app requires Debug DLLs, like opencv_core411d.dll)

                        I am building in Release mode.

                        @jhoney said in OpenCV 4.1.1 Imread() & Imwrite() Crashes Program ?:

                        "SamplePath.tiff" is a relative path. Is that file in the same folder as your application ?

                        Yes it is, but as stated before this is not the issue as the program does not even startup.

                        • What is very strange is that running the program from inside Qt I get the error: "The program has unexpectedly finished. The process was ended forcefully".

                        • But running the executable directly on my PC, it starts up fine.

                        • When running the program on another machine (with the required .DLLs copied into the release folder) I get this error:
                          0_1566406119377_Capture.PNG

                        J 1 Reply Last reply 22 Aug 2019, 02:02
                        0
                        • S Offline
                          S Offline
                          SGaist
                          Lifetime Qt Champion
                          wrote on 21 Aug 2019, 18:38 last edited by
                          #13

                          This usually is the sign of a mix of debug and release libraries.

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

                          R 1 Reply Last reply 21 Aug 2019, 19:13
                          0
                          • S SGaist
                            21 Aug 2019, 18:38

                            This usually is the sign of a mix of debug and release libraries.

                            R Offline
                            R Offline
                            R-P-H
                            wrote on 21 Aug 2019, 19:13 last edited by
                            #14

                            @sgaist said in OpenCV 4.1.1 Imread() & Imwrite() Crashes Program ?:

                            This usually is the sign of a mix of debug and release libraries.

                            I'm not sure how that's possible since I built OpenCV for release mode and the path to all the DLLs is the same.

                            1 Reply Last reply
                            0
                            • R R-P-H
                              21 Aug 2019, 16:46

                              @sgaist said in OpenCV 4.1.1 Imread() & Imwrite() Crashes Program ?:

                              Did you try to start your application with the debugger ?
                              What stack trace do you get ?

                              I did, the debugger just ends immediately with no output that I can see.

                              @jksh said in OpenCV 4.1.1 Imread() & Imwrite() Crashes Program ?:

                              @r-p-h said in OpenCV 4.1.1 Imread() & Imwrite() Crashes Program ?:

                              LIBS += -L"C:\opencv4-build-x64\install\x64\mingw\bin" -lopencv_core411
                              -lopencv_highgui411
                              -lopencv_imgproc411
                              -lopencv_imgcodecs411

                              You are linking to the Release DLLs. Are you building your app in Release mode or Debug mode? (A Debug mode app requires Debug DLLs, like opencv_core411d.dll)

                              I am building in Release mode.

                              @jhoney said in OpenCV 4.1.1 Imread() & Imwrite() Crashes Program ?:

                              "SamplePath.tiff" is a relative path. Is that file in the same folder as your application ?

                              Yes it is, but as stated before this is not the issue as the program does not even startup.

                              • What is very strange is that running the program from inside Qt I get the error: "The program has unexpectedly finished. The process was ended forcefully".

                              • But running the executable directly on my PC, it starts up fine.

                              • When running the program on another machine (with the required .DLLs copied into the release folder) I get this error:
                                0_1566406119377_Capture.PNG

                              J Offline
                              J Offline
                              JKSH
                              Moderators
                              wrote on 22 Aug 2019, 02:02 last edited by JKSH
                              #15

                              @r-p-h said in OpenCV 4.1.1 Imread() & Imwrite() Crashes Program ?:

                              • What is very strange is that running the program from inside Qt I get the error: "The program has unexpectedly finished. The process was ended forcefully".

                              • But running the executable directly on my PC, it starts up fine.

                              • When running the program on another machine (with the required .DLLs copied into the release folder) I get this error:
                                0_1566406119377_Capture.PNG

                              • When you run your .exe directly on your PC, it loads the correct DLLs.
                              • When you run your .exe from Qt Creator, it loads the wrong DLLs.
                              • You have copied the wrong DLLs to the other machine (OR, that other machine has incompatible DLLs in its PATH)

                              You should:

                              1. Make sure your program does not quit (for example, add system("pause"); at the end of main()).
                              2. Build your .exe and run it directly on your PC.
                              3. While it is still running, use ListDLLs to print every single DLL that is loaded: https://docs.microsoft.com/en-us/sysinternals/downloads/listdlls

                              Pay attention to the absolute paths of every single DLL that's reported by ListDLLs. What do you notice?

                              If you can't find any clues, repeat the process on your other machine. Run ListDLLs while the "Entry Point Not Found" error dialog is open. Compare the lists from your 2 machines.

                              No, the path to the DLLs is in my systems environment path.

                              I don't recommend adding DLLs to your global PATH. This is a common cause of DLL Hell.

                              Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

                              R 1 Reply Last reply 23 Aug 2019, 09:09
                              1
                              • J JKSH
                                22 Aug 2019, 02:02

                                @r-p-h said in OpenCV 4.1.1 Imread() & Imwrite() Crashes Program ?:

                                • What is very strange is that running the program from inside Qt I get the error: "The program has unexpectedly finished. The process was ended forcefully".

                                • But running the executable directly on my PC, it starts up fine.

                                • When running the program on another machine (with the required .DLLs copied into the release folder) I get this error:
                                  0_1566406119377_Capture.PNG

                                • When you run your .exe directly on your PC, it loads the correct DLLs.
                                • When you run your .exe from Qt Creator, it loads the wrong DLLs.
                                • You have copied the wrong DLLs to the other machine (OR, that other machine has incompatible DLLs in its PATH)

                                You should:

                                1. Make sure your program does not quit (for example, add system("pause"); at the end of main()).
                                2. Build your .exe and run it directly on your PC.
                                3. While it is still running, use ListDLLs to print every single DLL that is loaded: https://docs.microsoft.com/en-us/sysinternals/downloads/listdlls

                                Pay attention to the absolute paths of every single DLL that's reported by ListDLLs. What do you notice?

                                If you can't find any clues, repeat the process on your other machine. Run ListDLLs while the "Entry Point Not Found" error dialog is open. Compare the lists from your 2 machines.

                                No, the path to the DLLs is in my systems environment path.

                                I don't recommend adding DLLs to your global PATH. This is a common cause of DLL Hell.

                                R Offline
                                R Offline
                                R-P-H
                                wrote on 23 Aug 2019, 09:09 last edited by
                                #16

                                @jksh said in OpenCV 4.1.1 Imread() & Imwrite() Crashes Program ?:

                                • When you run your .exe directly on your PC, it loads the correct DLLs.
                                • When you run your .exe from Qt Creator, it loads the wrong DLLs.
                                • You have copied the wrong DLLs to the other machine (OR, that other machine has incompatible DLLs in its PATH)

                                You should:

                                1. Make sure your program does not quit (for example, add system("pause"); at the end of main()).
                                2. Build your .exe and run it directly on your PC.
                                3. While it is still running, use ListDLLs to print every single DLL that is loaded: https://docs.microsoft.com/en-us/sysinternals/downloads/listdlls

                                Pay attention to the absolute paths of every single DLL that's reported by ListDLLs. What do you notice?

                                If you can't find any clues, repeat the process on your other machine. Run ListDLLs while the "Entry Point Not Found" error dialog is open. Compare the lists from your 2 machines.

                                No, the path to the DLLs is in my systems environment path.

                                I don't recommend adding DLLs to your global PATH. This is a common cause of DLL Hell.

                                Hi, thanks for your help. So I ran listDLLs on both machines as you suggested and found that there were 3 discrepancies related to DLLs that I use:

                                • mingw64\bin\libgcc_s_seh-1.dll
                                • mingw64\bin\libwinpthread-1.dll
                                • mingw64\bin\libstdc++-6.dll

                                I found that these DLLs are located in both the Qt folder and minGW compiler folder. I replaced the Qt versions of the DLLs with the ones from the minGW folder and then the program ran fine on the other machine.

                                So now the .exe runs fine directly on my PC and the other machine, HOWEVER it is still instantly crashing when running it from Qt directly AS LONG AS THE IMREAD() AND IMWRITE() FUNCTIONS ARE THERE. If I comment them out it runs fine from inside Qt.

                                What do you think is the issue with Qt and OpenCV ? Maybe it's to do with the options I set when I built OpenCV from source with CMAKE ? It really doesn't make sense to me that the executable runs fine yet from inside Qt it crashes ? I've never had that happen before.

                                I always use this article as guidance: How_to_setup_Qt_and_openCV_on_Windows where it says to add OpenCV and minGW to the environment path. I've never had issues before, only now with OpenCV v4.1.1.

                                J 2 Replies Last reply 23 Aug 2019, 14:08
                                0
                                • R R-P-H
                                  23 Aug 2019, 09:09

                                  @jksh said in OpenCV 4.1.1 Imread() & Imwrite() Crashes Program ?:

                                  • When you run your .exe directly on your PC, it loads the correct DLLs.
                                  • When you run your .exe from Qt Creator, it loads the wrong DLLs.
                                  • You have copied the wrong DLLs to the other machine (OR, that other machine has incompatible DLLs in its PATH)

                                  You should:

                                  1. Make sure your program does not quit (for example, add system("pause"); at the end of main()).
                                  2. Build your .exe and run it directly on your PC.
                                  3. While it is still running, use ListDLLs to print every single DLL that is loaded: https://docs.microsoft.com/en-us/sysinternals/downloads/listdlls

                                  Pay attention to the absolute paths of every single DLL that's reported by ListDLLs. What do you notice?

                                  If you can't find any clues, repeat the process on your other machine. Run ListDLLs while the "Entry Point Not Found" error dialog is open. Compare the lists from your 2 machines.

                                  No, the path to the DLLs is in my systems environment path.

                                  I don't recommend adding DLLs to your global PATH. This is a common cause of DLL Hell.

                                  Hi, thanks for your help. So I ran listDLLs on both machines as you suggested and found that there were 3 discrepancies related to DLLs that I use:

                                  • mingw64\bin\libgcc_s_seh-1.dll
                                  • mingw64\bin\libwinpthread-1.dll
                                  • mingw64\bin\libstdc++-6.dll

                                  I found that these DLLs are located in both the Qt folder and minGW compiler folder. I replaced the Qt versions of the DLLs with the ones from the minGW folder and then the program ran fine on the other machine.

                                  So now the .exe runs fine directly on my PC and the other machine, HOWEVER it is still instantly crashing when running it from Qt directly AS LONG AS THE IMREAD() AND IMWRITE() FUNCTIONS ARE THERE. If I comment them out it runs fine from inside Qt.

                                  What do you think is the issue with Qt and OpenCV ? Maybe it's to do with the options I set when I built OpenCV from source with CMAKE ? It really doesn't make sense to me that the executable runs fine yet from inside Qt it crashes ? I've never had that happen before.

                                  I always use this article as guidance: How_to_setup_Qt_and_openCV_on_Windows where it says to add OpenCV and minGW to the environment path. I've never had issues before, only now with OpenCV v4.1.1.

                                  J Offline
                                  J Offline
                                  JKSH
                                  Moderators
                                  wrote on 23 Aug 2019, 14:08 last edited by JKSH
                                  #17

                                  @r-p-h said in OpenCV 4.1.1 Imread() & Imwrite() Crashes Program ?:

                                  I found that these DLLs are located in both the Qt folder and minGW compiler folder. I replaced the Qt versions of the DLLs with the ones from the minGW folder and then the program ran fine on the other machine.

                                  You have 2 different versions/variants of MinGW on your machine that are incompatible with each other.

                                  You must make sure that both Qt and OpenCV are both compiled with the same version/variant of MinGW.

                                  It really doesn't make sense to me that the executable runs fine yet from inside Qt it crashes ? I've never had that happen before.

                                  Like I said before, your system is loading different DLLs in those 2 different cases.

                                  I always use this article as guidance: How_to_setup_Qt_and_openCV_on_Windows where it says to add OpenCV and minGW to the environment path. I've never had issues before, only now with OpenCV v4.1.1.

                                  You did not have incompatible versions of MinGW before. Now you do.

                                  Questions:

                                  1. What version(s) of Qt do you have?
                                  2. How did you install Qt?
                                  3. What version(s) on MinGW do you have?
                                  4. How did you install MinGW?
                                  5. Which version of MinGW did you use to build OpenCV?

                                  Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

                                  R 1 Reply Last reply 26 Aug 2019, 09:11
                                  1
                                  • J JKSH
                                    23 Aug 2019, 14:08

                                    @r-p-h said in OpenCV 4.1.1 Imread() & Imwrite() Crashes Program ?:

                                    I found that these DLLs are located in both the Qt folder and minGW compiler folder. I replaced the Qt versions of the DLLs with the ones from the minGW folder and then the program ran fine on the other machine.

                                    You have 2 different versions/variants of MinGW on your machine that are incompatible with each other.

                                    You must make sure that both Qt and OpenCV are both compiled with the same version/variant of MinGW.

                                    It really doesn't make sense to me that the executable runs fine yet from inside Qt it crashes ? I've never had that happen before.

                                    Like I said before, your system is loading different DLLs in those 2 different cases.

                                    I always use this article as guidance: How_to_setup_Qt_and_openCV_on_Windows where it says to add OpenCV and minGW to the environment path. I've never had issues before, only now with OpenCV v4.1.1.

                                    You did not have incompatible versions of MinGW before. Now you do.

                                    Questions:

                                    1. What version(s) of Qt do you have?
                                    2. How did you install Qt?
                                    3. What version(s) on MinGW do you have?
                                    4. How did you install MinGW?
                                    5. Which version of MinGW did you use to build OpenCV?
                                    R Offline
                                    R Offline
                                    R-P-H
                                    wrote on 26 Aug 2019, 09:11 last edited by
                                    #18

                                    @jksh said in OpenCV 4.1.1 Imread() & Imwrite() Crashes Program ?:

                                    You have 2 different versions/variants of MinGW on your machine that are incompatible with each other.

                                    I have a 32bit minGW compiler and a 64bit minGW compiler.

                                    You must make sure that both Qt and OpenCV are both compiled with the same version/variant of MinGW.

                                    Like I said before, your system is loading different DLLs in those 2 different cases.

                                    Both are using the 64bit compiler.

                                    You did not have incompatible versions of MinGW before. Now you do.

                                    No the environment was exactly the same before. And my other projects with OpenCV V2 and V3 work fine.

                                    Questions:

                                    1. What version(s) of Qt do you have?

                                    5.10.1 for 32bit Kit and 5.5.0 for 64bit kit.

                                    1. How did you install Qt?

                                    Normally through the installer.

                                    1. What version(s) on MinGW do you have?

                                    5.3.0 32bit and I'm not sure of the 64bit version.

                                    1. How did you install MinGW?

                                    32bit came with Qt. 64bit I downloaded.

                                    1. Which version of MinGW did you use to build OpenCV?

                                    64bit.

                                    I'm beginning to think that the problem is something to do with building OPENCV V4.1.1.

                                    1 Reply Last reply
                                    0
                                    • R R-P-H
                                      23 Aug 2019, 09:09

                                      @jksh said in OpenCV 4.1.1 Imread() & Imwrite() Crashes Program ?:

                                      • When you run your .exe directly on your PC, it loads the correct DLLs.
                                      • When you run your .exe from Qt Creator, it loads the wrong DLLs.
                                      • You have copied the wrong DLLs to the other machine (OR, that other machine has incompatible DLLs in its PATH)

                                      You should:

                                      1. Make sure your program does not quit (for example, add system("pause"); at the end of main()).
                                      2. Build your .exe and run it directly on your PC.
                                      3. While it is still running, use ListDLLs to print every single DLL that is loaded: https://docs.microsoft.com/en-us/sysinternals/downloads/listdlls

                                      Pay attention to the absolute paths of every single DLL that's reported by ListDLLs. What do you notice?

                                      If you can't find any clues, repeat the process on your other machine. Run ListDLLs while the "Entry Point Not Found" error dialog is open. Compare the lists from your 2 machines.

                                      No, the path to the DLLs is in my systems environment path.

                                      I don't recommend adding DLLs to your global PATH. This is a common cause of DLL Hell.

                                      Hi, thanks for your help. So I ran listDLLs on both machines as you suggested and found that there were 3 discrepancies related to DLLs that I use:

                                      • mingw64\bin\libgcc_s_seh-1.dll
                                      • mingw64\bin\libwinpthread-1.dll
                                      • mingw64\bin\libstdc++-6.dll

                                      I found that these DLLs are located in both the Qt folder and minGW compiler folder. I replaced the Qt versions of the DLLs with the ones from the minGW folder and then the program ran fine on the other machine.

                                      So now the .exe runs fine directly on my PC and the other machine, HOWEVER it is still instantly crashing when running it from Qt directly AS LONG AS THE IMREAD() AND IMWRITE() FUNCTIONS ARE THERE. If I comment them out it runs fine from inside Qt.

                                      What do you think is the issue with Qt and OpenCV ? Maybe it's to do with the options I set when I built OpenCV from source with CMAKE ? It really doesn't make sense to me that the executable runs fine yet from inside Qt it crashes ? I've never had that happen before.

                                      I always use this article as guidance: How_to_setup_Qt_and_openCV_on_Windows where it says to add OpenCV and minGW to the environment path. I've never had issues before, only now with OpenCV v4.1.1.

                                      J Offline
                                      J Offline
                                      JKSH
                                      Moderators
                                      wrote on 26 Aug 2019, 11:34 last edited by JKSH
                                      #19

                                      @r-p-h said in OpenCV 4.1.1 Imread() & Imwrite() Crashes Program ?:

                                      So I ran listDLLs on both machines as you suggested and found that there were 3 discrepancies related to DLLs that I use:

                                      • mingw64\bin\libgcc_s_seh-1.dll
                                      • mingw64\bin\libwinpthread-1.dll
                                      • mingw64\bin\libstdc++-6.dll

                                      I found that these DLLs are located in both the Qt folder and minGW compiler folder. I replaced the Qt versions of the DLLs with the ones from the minGW folder and then the program ran fine on the other machine.

                                      The above shows that the DLLs that were previously in the Qt folder are incompatible with the DLLs in the MinGW compiler folder.

                                      Could your build of OpenCV 4.1.1 be similarly contaminated?

                                      I always use this article as guidance: How_to_setup_Qt_and_openCV_on_Windows where it says to add OpenCV and minGW to the environment path. I've never had issues before, only now with OpenCV v4.1.1.

                                      ...

                                      No the environment was exactly the same before. And my other projects with OpenCV V2 and V3 work fine.

                                      Does that mean you have multiple versions of OpenCV in your PATH at the same time?

                                      Did you use the same version of MinGW to build all your versions of OpenCV?

                                      32bit came with Qt. 64bit I downloaded.

                                      Qt 5.12 and Qt 5.13 come pre-built for MinGW 7.3.0 64-bit.

                                      What do you think of using one of those? That way, you can use an official build of Qt and its compiler to build your copy of OpenCV 4.1.1; you don't need a custom-built copy of Qt? (Note: Qt 5.5 reached end-of-life in March 2018)

                                      Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

                                      R 1 Reply Last reply 26 Aug 2019, 13:06
                                      2
                                      • J JKSH
                                        26 Aug 2019, 11:34

                                        @r-p-h said in OpenCV 4.1.1 Imread() & Imwrite() Crashes Program ?:

                                        So I ran listDLLs on both machines as you suggested and found that there were 3 discrepancies related to DLLs that I use:

                                        • mingw64\bin\libgcc_s_seh-1.dll
                                        • mingw64\bin\libwinpthread-1.dll
                                        • mingw64\bin\libstdc++-6.dll

                                        I found that these DLLs are located in both the Qt folder and minGW compiler folder. I replaced the Qt versions of the DLLs with the ones from the minGW folder and then the program ran fine on the other machine.

                                        The above shows that the DLLs that were previously in the Qt folder are incompatible with the DLLs in the MinGW compiler folder.

                                        Could your build of OpenCV 4.1.1 be similarly contaminated?

                                        I always use this article as guidance: How_to_setup_Qt_and_openCV_on_Windows where it says to add OpenCV and minGW to the environment path. I've never had issues before, only now with OpenCV v4.1.1.

                                        ...

                                        No the environment was exactly the same before. And my other projects with OpenCV V2 and V3 work fine.

                                        Does that mean you have multiple versions of OpenCV in your PATH at the same time?

                                        Did you use the same version of MinGW to build all your versions of OpenCV?

                                        32bit came with Qt. 64bit I downloaded.

                                        Qt 5.12 and Qt 5.13 come pre-built for MinGW 7.3.0 64-bit.

                                        What do you think of using one of those? That way, you can use an official build of Qt and its compiler to build your copy of OpenCV 4.1.1; you don't need a custom-built copy of Qt? (Note: Qt 5.5 reached end-of-life in March 2018)

                                        R Offline
                                        R Offline
                                        R-P-H
                                        wrote on 26 Aug 2019, 13:06 last edited by
                                        #20

                                        @jksh said in OpenCV 4.1.1 Imread() & Imwrite() Crashes Program ?:

                                        The above shows that the DLLs that were previously in the Qt folder are incompatible with the DLLs in the MinGW compiler folder.

                                        Could your build of OpenCV 4.1.1 be similarly contaminated?

                                        In what sense, because I specified the correct paths to the compiler and Qt folders...

                                        Does that mean you have multiple versions of OpenCV in your PATH at the same time?

                                        Yes, although I have used this setup across multiple projects using different versions of opencv and I didn't run into any problems.

                                        Did you use the same version of MinGW to build all your versions of OpenCV?

                                        No, I have 32bit builds of OpenCV and 64bit builds.

                                        Qt 5.12 and Qt 5.13 come pre-built for MinGW 7.3.0 64-bit.

                                        What do you think of using one of those? That way, you can use an official build of Qt and its compiler to build your copy of OpenCV 4.1.1; you don't need a custom-built copy of Qt? (Note: Qt 5.5 reached end-of-life in March 2018)

                                        That was exactly what I was looking for. Are you sure the 64bit compiler is available now with Qt ? And if so, when was it added because I did the custom setup like 6 months ago specifically because Qt only shipped with a 32bit minGW compiler ?

                                        J 1 Reply Last reply 26 Aug 2019, 13:45
                                        0
                                        • R R-P-H
                                          26 Aug 2019, 13:06

                                          @jksh said in OpenCV 4.1.1 Imread() & Imwrite() Crashes Program ?:

                                          The above shows that the DLLs that were previously in the Qt folder are incompatible with the DLLs in the MinGW compiler folder.

                                          Could your build of OpenCV 4.1.1 be similarly contaminated?

                                          In what sense, because I specified the correct paths to the compiler and Qt folders...

                                          Does that mean you have multiple versions of OpenCV in your PATH at the same time?

                                          Yes, although I have used this setup across multiple projects using different versions of opencv and I didn't run into any problems.

                                          Did you use the same version of MinGW to build all your versions of OpenCV?

                                          No, I have 32bit builds of OpenCV and 64bit builds.

                                          Qt 5.12 and Qt 5.13 come pre-built for MinGW 7.3.0 64-bit.

                                          What do you think of using one of those? That way, you can use an official build of Qt and its compiler to build your copy of OpenCV 4.1.1; you don't need a custom-built copy of Qt? (Note: Qt 5.5 reached end-of-life in March 2018)

                                          That was exactly what I was looking for. Are you sure the 64bit compiler is available now with Qt ? And if so, when was it added because I did the custom setup like 6 months ago specifically because Qt only shipped with a 32bit minGW compiler ?

                                          J Offline
                                          J Offline
                                          JKSH
                                          Moderators
                                          wrote on 26 Aug 2019, 13:45 last edited by
                                          #21

                                          @r-p-h said in OpenCV 4.1.1 Imread() & Imwrite() Crashes Program ?:

                                          In what sense

                                          In the DLL Hell sense.

                                          Yes, although I have used this setup across multiple projects using different versions of opencv and I didn't run into any problems.

                                          Can you be 100% sure that that your current problems aren't caused by this setup?

                                          No, I have 32bit builds of OpenCV and 64bit builds.

                                          ...and all of those different versions of MinGW and OpenCV are in your PATH...?

                                          Please do yourself a favour and remove them all from your PATH. You don't need them in the PATH. This type of setup has caused many, many headaches over the years.

                                          That was exactly what I was looking for. Are you sure the 64bit compiler is available now with Qt ? And if so, when was it added because I did the custom setup like 6 months ago specifically because Qt only shipped with a 32bit minGW compiler ?

                                          Yes, I'm sure. It was added with Qt 5.12.0, which was released in December 2018.

                                          Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

                                          R 1 Reply Last reply 26 Aug 2019, 17:55
                                          2

                                          11/23

                                          20 Aug 2019, 11:01

                                          • Login

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