"No such file or directory" when I switch to Release mode



  • This is my MainWindow.h

    #ifndef MAINWINDOW_H
    #define MAINWINDOW_H
    
    #include <QMainWindow>
    #include <QMediaPlayer>
    
    namespace Ui
    {
        class MainWindow;
    }
    
    class MainWindow : public QMainWindow
    { ... }
    

    The #include<QMediaPlayer> gives an error when compiling in Release mode
    But it compiles and runs fine in Debug mode.

    Why? This is my kit configuration:
    0_1509622250064_123.jpg

    Thanks in advance!



  • @devhobby
    I think you need to copy file "Qt5Multimedia.dll" in your release directory. In Debug mode there is a link to Qt folder with all "*.dll" files, but in Release mode there isn't.



  • If it is failing to compile then I think we need to see the .pro file.



  • @devhobby said in "No such file or directory" when I switch to Release mode:

    The #include<QMediaPlayer> gives an error when compiling in Release mode

    Would also be heplfull to see the actual error message, preferably quoted, not abstract.



  • @Stoyan @mranger90 @J-Hilk

    Now the program starts in Release mode from the QtCreator IDE, but it doesn't when I double click the .exe manually.

    0_1509626579670_123.jpg

    Maybe I have more dependencies to solve: but which ones???


  • Moderators



  • @devhobby ah, qt comes with a small console application that helps you in your deployment efforts:

    windeployqt

    Use that one and in 95% of all case you won't need to copy any dependencies by hand.



  • @J.Hilk
    Yes I watched a video on YouTube showing this method.

    But unfortunately I belong to that 5% of cases where it doesn't work.

    My command line:

    C:\Users\Me\Documents\QtProjects\build-untitled1-Desktop_Qt_5_9_2_MSVC2017_64bit-Release\release > windeployqt.exe --quick .

    After I launched this command, my folder now looks like this:

    0_1509627508011_123.jpg

    But launching the .exe shows the exact same error... nothing changed...


  • Moderators

    @devhobby said in "No such file or directory" when I switch to Release mode:

    C:\Users\Me\Documents\QtProjects\build-untitled1-Desktop_Qt_5_9_2_MSVC2017_64bit-Release\release > windeployqt.exe --quick

    Should be

    C:\Users\Me\Documents\QtProjects\build-untitled1-Desktop_Qt_5_9_2_MSVC2017_64bit-Release\release > windeployqt.exe . --quick
    

    You need to pass either the executable or directory containing your executable to windeployqt as described in the link I posted.
    You can also use http://www.dependencywalker.com/ to check whether any libraries are missing.



  • @jsulm said in "No such file or directory" when I switch to Release mode:

    Should be

    C:\Users\Me\Documents\QtProjects\build-untitled1-Desktop_Qt_5_9_2_MSVC2017_64bit-Release\release > windeployqt.exe . --quick
    

    Yes I tried putting the dot before --quick but the result is the same. I don't know why, but the application still fails to start...

    Dependency Walker tells me this

    0_1509629911448_1234.jpg

    And the list continues...

    Also, why libgcc if I compiled with MSVC2017?


  • Moderators

    @devhobby Is it possible that you copied Qt5Multimedia from MinGW Qt?
    Maybe you should delete the build folder, rerun qmake and build again (after checking that you're using the correct Kit).
    Also which windeployqt.exe did you use? You should call it using an absolute path to make sure you're using the correct one.



  • @jsulm said in "No such file or directory" when I switch to Release mode:

    @devhobby Is it possible that you copied Qt5Multimedia from MinGW Qt?
    Maybe you should delete the build folder, rerun qmake and build again (after checking that you're using the correct Kit).
    Also which windeployqt.exe did you use? You should call it using an absolute path to make sure you're using the correct one.

    I deleted the build folder and re-built the project from QtCreator.
    Then I ran windeployqt, but this time I didn't copy-paste anything manually

    And it worked...
    Previously, I had copied and pasted some .dlls manually from Qt's bin folder.

    Right now the application runs and works perfectly.

    I'm afraid I'll have similar problems in the future, so a couple of questions to prevent any issue from happening:

    • Will the use of windeploy.exe work everytime I want to deploy any Qt dekstop applicaton to Windows?
    • If not, what should I do? Dependency Walker seems to be confusing most of the times
    • In the actual release folder, is there something I can delete to reduce the overall program size?
    • On the link you gave me initially there is Static Linking. When should I use it?

  • Moderators

    @devhobby

    • Nobody can guarantee this especially if you're using any third party libraries
    • You should find out what is missing, for example using Dependency Walker
    • You can delete everything not needed, it depends what is in the build directory. For example you can delete all object files (*.obj)
    • Statically linked libraries are used to create an executable which does not depend on shared libraries (all static dependencies are put into the executable). You should not use it if you don't really know what you're doing as you would need to build Qt and all dependencies by yourself! And IMPORTANT: using statically built Qt requires you either to buy a commercial Qt license or release your software under an open source license!


  • @devhobby to add to @jsulm , you run the deployment tool directly inside your release folder. That folder contains all kinds of temporary files (moc files and obj files mostly).

    Just take your *.exe file copy it in a fresh and empty folder and run windeployqt on that file, so you don't have to worry - too much - about unneeded files.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.