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. executable runs fine from local directory / throws error with IDE.
Forum Updated to NodeBB v4.3 + New Features

executable runs fine from local directory / throws error with IDE.

Scheduled Pinned Locked Moved General and Desktop
27 Posts 4 Posters 6.8k Views 4 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.
  • JKSHJ Offline
    JKSHJ Offline
    JKSH
    Moderators
    wrote on last edited by JKSH
    #17

    @Technologist said:

    That shows that the configuration problem of .pro file was human error. It found my qt header files. Thanks for the pointer on opel GL etc. This solution rules out a single error behind both. This problem is fixed however the first problem persists: the IDE crashes when I build the "Show Picture" routine, but runs perfectly when I execute it from build directory. Do I need to close out this ticket and reopen it or finish out here?

    Thanks for your time

    You're welcome :)

    Yes, this little excursion helped us to establish that your installation of Qt and the IDE are fine. So, the problem probably lies in your project configuration or environment.

    I just noticed that you have Qt and Qt Creator in your PATH. This is very bad, because they both contain different (and incompatible) versions of the same DLL (e.g. Qt5Core.dll). Remove them from your PATH. There is no need for anything Qt-related to be in the PATH, and having them there is the cause of many mysterious crashes.

    After cleaning your PATH, try running your program again. (To do it outside the IDE the proper way, see http://wiki.qt.io/Deploy_an_Application_on_Windows )

    In general, MSVC and MinGW are incompatible. Qt Creator is a Qt-built program too, which uses MSVC 2010-built Qt DLLs. I also noticed that your copy OpenCV is built with MSVC 2012. I'm not sure if this is compatible with your MinGW-built app.

    You can continue posting here, as it's still about your original post.

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

    1 Reply Last reply
    0
    • TechnologistT Offline
      TechnologistT Offline
      Technologist
      wrote on last edited by Technologist
      #18

      FYI the platform was built using cmake and mingw, not MSVS (I don't have msvs on the system.) -- if that's coming across from the ?path?. Was it this line: %OPENCV%\buildx86\vc11Honestly I think I put it in the path mistakenly. Can I remove it?

      OK cleaned my path. No more missing qt files with Widgets addition to pro file. Application still continue to crash in intialization phase. Sometimes it will throw this error a lot of the time or just open a window and crash. Below it can't find an opencv file.

      The program can't start because libgcc_s_dw2-1.dll is missing from your computer Try installing the program to fix this problem.
      

      New local path: C:\OpenCV-2.3.1\bin;C:\OpenCV-2.3.1\install\include\opencv2;C:\OpenCV-2.3.1\lib;
      System path:%OPENCV%\build\x86\vc11\bin; c:\OpenCV-2.3.1\bin;C:\opencv-win\opencv\sources\modules;

      error :C:\Users\Technologist\Documents\NewOne\main.cpp:2: error: opencv2/core/core.hpp: No such file or directory #include <opencv2/core/core.hpp>
      ^
      pro. file:

      QT       += core
      
      QT       += gui
      QT       += widgets
      
      TARGET = NewOne
      CONFIG   += console
      CONFIG   -= app_bundle
      
      TEMPLATE = app
      
      SOURCES += main.cpp
      
      INCLUDEPATH += "C:/OpenCV-2.3.1/install/include/opencv2/"
      
      LIBS += -LC:\OpenCV-2.3.1\lib\
          -lopencv_core2411.dll.a \
          -lopencv_highgui2411.dl.al \
          -lopencv_imgproc2411.dll.a \
          -lopencv_features2d2411.dll.a \
          -lopencv_calib3d2411.dll.a
      
      #include <QCoreApplication>
      #include <opencv2/core/core.hpp>
      #include <opencv2/highgui/highgui.hpp>
      int main() {
              // read an image
              cv::Mat image= cv::imread("img.jpg");
              // create image window named "My Image"
              cv::namedWindow("My Image");
              // show the image on window
              cv::imshow("My Image", image);
              // wait key for 5000 ms
              cv::waitKey(5000);
              return 1;
      }
      
      
      JKSHJ 1 Reply Last reply
      0
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by SGaist
        #19

        Don't include opencv2 in your INCLUDEPATH entry

        INCLUDEPATH += "C:/OpenCV-2.3.1/install/include/"

        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
        • TechnologistT Offline
          TechnologistT Offline
          Technologist
          wrote on last edited by Technologist
          #20

          I don't see any opencv2 in your includepath unless you are referring to the opencv2 down the file directory from there.

          INCLUDEPATH += "C:\OpenCV-2.3.1\install\include\opencv2"
          

          Sorry, now I am feeling newbish.

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

            That's the point. Since you use:

            #include <opencv2/core/core.hpp>

            If you use INCLUDEPATH += "C:/OpenCV-2.3.1/install/include/opencv2/" then the headers won't be found because you are trying to include a file that would be searched like:
            "C:/OpenCV-2.3.1/install/include/opencv2/opencv2/core/core.hpp".

            So either remove opencv2 from your include lines or remove it from your INCLUDEPATH line.

            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
            • TechnologistT Technologist

              FYI the platform was built using cmake and mingw, not MSVS (I don't have msvs on the system.) -- if that's coming across from the ?path?. Was it this line: %OPENCV%\buildx86\vc11Honestly I think I put it in the path mistakenly. Can I remove it?

              OK cleaned my path. No more missing qt files with Widgets addition to pro file. Application still continue to crash in intialization phase. Sometimes it will throw this error a lot of the time or just open a window and crash. Below it can't find an opencv file.

              The program can't start because libgcc_s_dw2-1.dll is missing from your computer Try installing the program to fix this problem.
              

              New local path: C:\OpenCV-2.3.1\bin;C:\OpenCV-2.3.1\install\include\opencv2;C:\OpenCV-2.3.1\lib;
              System path:%OPENCV%\build\x86\vc11\bin; c:\OpenCV-2.3.1\bin;C:\opencv-win\opencv\sources\modules;

              error :C:\Users\Technologist\Documents\NewOne\main.cpp:2: error: opencv2/core/core.hpp: No such file or directory #include <opencv2/core/core.hpp>
              ^
              pro. file:

              QT       += core
              
              QT       += gui
              QT       += widgets
              
              TARGET = NewOne
              CONFIG   += console
              CONFIG   -= app_bundle
              
              TEMPLATE = app
              
              SOURCES += main.cpp
              
              INCLUDEPATH += "C:/OpenCV-2.3.1/install/include/opencv2/"
              
              LIBS += -LC:\OpenCV-2.3.1\lib\
                  -lopencv_core2411.dll.a \
                  -lopencv_highgui2411.dl.al \
                  -lopencv_imgproc2411.dll.a \
                  -lopencv_features2d2411.dll.a \
                  -lopencv_calib3d2411.dll.a
              
              #include <QCoreApplication>
              #include <opencv2/core/core.hpp>
              #include <opencv2/highgui/highgui.hpp>
              int main() {
                      // read an image
                      cv::Mat image= cv::imread("img.jpg");
                      // create image window named "My Image"
                      cv::namedWindow("My Image");
                      // show the image on window
                      cv::imshow("My Image", image);
                      // wait key for 5000 ms
                      cv::waitKey(5000);
                      return 1;
              }
              
              
              JKSHJ Offline
              JKSHJ Offline
              JKSH
              Moderators
              wrote on last edited by
              #22

              @Technologist said:

              FYI the platform was built using cmake and mingw, not MSVS (I don't have msvs on the system.) -- if that's coming across from the ?path?. Was it this line: %OPENCV%\buildx86\vc11

              Yes, it was that line. "VC11" represents Visual Studio 2012.

              Honestly I think I put it in the path mistakenly. Can I remove it?

              I don't know, as I've never used OpenCV myself. How does OpenCV recommend you set up your libraries?

              OK cleaned my path. No more missing qt files with Widgets addition to pro file. Application still continue to crash in intialization phase. Sometimes it will throw this error a lot of the time or just open a window and crash. Below it can't find an opencv file.

              The program can't start because libgcc_s_dw2-1.dll is missing from your computer Try installing the program to fix this problem.
              

              That's not an error that can only happen "some of the time" for a particular setup -- it either happens all of the time, or it won't happen.

              I suspect that you are trying to launch your app in different ways but then combining their results into one observation. Please be systematic in your investigations: Describe what you do leading up to a specific crash (e.g. "This happens I try to launch my app from the IDE" and "That happens when I try to launch my app from the build directory")

              Note: Launching from a build directory is like trying to run a deployed application. Follow http://wiki.qt.io/Deploy_an_Application_on_Windows carefully

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

              1 Reply Last reply
              0
              • TechnologistT Offline
                TechnologistT Offline
                Technologist
                wrote on last edited by Technologist
                #23

                I suspect that you are trying to launch your app in different ways but then combining their results into one observation.. Please be systematic in your investigations.

                The more systematic the better. I am trying to get all my apps, as with any good scientific analysis, running from the same baseline. We have done most of that already by clearing up the header and include file issues, and this has prepared the way for a final solution, easier to see with less stuff being wrong. Now its finally the library error they all seem to share.

                Thx for your time.

                Below: :-1: error: cannot find -llibopencv_core2411.dll.a  :-1: error: cannot find -llibopencv_highgui2411.dll.a
                

                .pro

                QT       += core
                QT       += widgets
                QT       += gui
                
                TARGET = AnotherWack
                CONFIG   += console
                CONFIG   -= app_bundle
                
                TEMPLATE = app
                
                
                SOURCES += main.cpp
                
                INCLUDEPATH += "C:/OpenCV-2.3.1/install/include/"
                
                LIBS += -LC:/OpenCV-2.3.1/lib \
                        -llibopencv_core2411.dll.a \
                        -llibopencv_highgui2411.dll.a \
                

                main

                #include <QCoreApplication>
                #include <opencv2/core/core.hpp>
                #include <opencv2/highgui/highgui.hpp>
                
                int main() {
                        // read an image
                        cv::Mat image= cv::imread("img.jpg");
                        // create image window named "My Image"
                        cv::namedWindow("My Image");
                        // show the image on window
                        cv::imshow("My Image", image);
                        // wait key for 5000 ms
                        cv::waitKey(5000);
                        return 1;
                }
                
                1 Reply Last reply
                0
                • M Offline
                  M Offline
                  mcosta
                  wrote on last edited by
                  #24

                  @Technologist said:

                  -llibopencv_core2411.dll.a

                  Hi,

                  if you use the flag -l you have to omit the lib prefix and the extensions -llibopencv_core2411

                  Once your problem is solved don't forget to:

                  • Mark the thread as SOLVED using the Topic Tool menu
                  • Vote up the answer(s) that helped you to solve the issue

                  You can embed images using (http://imgur.com/) or (http://postimage.org/)

                  1 Reply Last reply
                  0
                  • TechnologistT Offline
                    TechnologistT Offline
                    Technologist
                    wrote on last edited by Technologist
                    #25

                    I'm no longer getting the include and library errors that I was. The main error was getting a build error with a working executable. Now after installing these changes, I get the build error and executable error (they are the same) . Somehow, am chagrin to say, I can't account for the change.They both crash now. I wanted to try putting the DLL in with the executable to see if that would work, but the relevant 5 project dlls were gone (??). I had to poach them from an apparent windows directory vc 11 and copy them to the library that couldn't find them. The same error would continue.

                    Present code:
                    main.cpp

                    #include <QCoreApplication>
                    #include <opencv2/core/core.hpp>
                    #include <opencv2/highgui/highgui.hpp>
                    
                    int main() {
                    
                        // read an image
                        cv::Mat image= cv::imread("img.jpg");
                        // create image window named "My Image"
                        cv::namedWindow("My Image");
                        // show the image on window
                        cv::imshow("My Image", image);
                        // wait key for 5000 ms
                        cv::waitKey(5000);
                    
                        return 1;
                    }
                    

                    .pro

                    
                    QT       += core
                    
                    QT       += gui
                    QT       += widgets
                    
                    TARGET = NewOne
                    CONFIG   += console
                    CONFIG   -= app_bundle
                    
                    TEMPLATE = app
                    
                    SOURCES += main.cpp
                    
                    INCLUDEPATH += C:/OpenCV-2.3.1/install/include/
                    
                    LIBS += -LC:\OpenCV-2.3.1\lib\
                        -lopencv_core2411 \
                        -lopencv_highgui2411 \
                        -lopencv_imgproc2411 \
                        -lopencv_features2d2411\
                        -lopencv_calib3d2411
                    1 Reply Last reply
                    0
                    • SGaistS Offline
                      SGaistS Offline
                      SGaist
                      Lifetime Qt Champion
                      wrote on last edited by
                      #26

                      Then just to be sure: which Qt package are you using ?

                      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
                      • TechnologistT Offline
                        TechnologistT Offline
                        Technologist
                        wrote on last edited by Technologist
                        #27

                        The version is qt 5.4
                        Using 64 bit os

                        On a few directories I made them the version of the tutorial (OpenCV-2.3.1) to stay on track, but the overall version was 2.4.11 that was downloaded and installed.

                        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