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. error: cannot open output file
Forum Update on Monday, May 27th 2025

error: cannot open output file

Scheduled Pinned Locked Moved Solved General and Desktop
18 Posts 3 Posters 3.0k 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.
  • N Offline
    N Offline
    nekkceb
    wrote on 17 Jan 2024, 17:37 last edited by
    #1

    After running my code in debug mode, stop the process and make changes, when I try to rebuild or re-run in the debugger I get this compiler error:
    :-1: error: cannot open output file dynamicspline.exe: Invalid argument.
    There is an old post related to this, but in that case, it seems they could find the process still running in the task manager. My application is a windows GUI, not a console application, and I do not see any processes related to it in the task manager that I can kill. The only thing that works for me is to exit QTCreator, then find the build directory (e.g. build-dynamicspline-Desktop_Qt_6_2_8_MinGW_64_bit-Debug) and rename it to something like 'jumk'.. I can then re-start Qt-Creator, re-buiuld and ruyn again. But this is a pain to deal with. AND it just started, i was working fine a few days ago!
    Windows 10, latest build, Qt Creator 11.0.0, compiling with Desktop Qt 6.2.8 MinGW 64-bit

    A N 2 Replies Last reply 17 Jan 2024, 18:58
    0
    • N nekkceb
      17 Jan 2024, 17:37

      After running my code in debug mode, stop the process and make changes, when I try to rebuild or re-run in the debugger I get this compiler error:
      :-1: error: cannot open output file dynamicspline.exe: Invalid argument.
      There is an old post related to this, but in that case, it seems they could find the process still running in the task manager. My application is a windows GUI, not a console application, and I do not see any processes related to it in the task manager that I can kill. The only thing that works for me is to exit QTCreator, then find the build directory (e.g. build-dynamicspline-Desktop_Qt_6_2_8_MinGW_64_bit-Debug) and rename it to something like 'jumk'.. I can then re-start Qt-Creator, re-buiuld and ruyn again. But this is a pain to deal with. AND it just started, i was working fine a few days ago!
      Windows 10, latest build, Qt Creator 11.0.0, compiling with Desktop Qt 6.2.8 MinGW 64-bit

      N Offline
      N Offline
      nekkceb
      wrote on 16 Feb 2024, 17:48 last edited by nekkceb
      #18
      This post is deleted!
      1 Reply Last reply
      1
      • N nekkceb
        17 Jan 2024, 17:37

        After running my code in debug mode, stop the process and make changes, when I try to rebuild or re-run in the debugger I get this compiler error:
        :-1: error: cannot open output file dynamicspline.exe: Invalid argument.
        There is an old post related to this, but in that case, it seems they could find the process still running in the task manager. My application is a windows GUI, not a console application, and I do not see any processes related to it in the task manager that I can kill. The only thing that works for me is to exit QTCreator, then find the build directory (e.g. build-dynamicspline-Desktop_Qt_6_2_8_MinGW_64_bit-Debug) and rename it to something like 'jumk'.. I can then re-start Qt-Creator, re-buiuld and ruyn again. But this is a pain to deal with. AND it just started, i was working fine a few days ago!
        Windows 10, latest build, Qt Creator 11.0.0, compiling with Desktop Qt 6.2.8 MinGW 64-bit

        A Offline
        A Offline
        Axel Spoerl
        Moderators
        wrote on 17 Jan 2024, 18:58 last edited by
        #2

        @nekkceb
        Technically speaking, Windows blocks your binary while being executed in the debugger. That makes sense, you don't want to change horses on the fly.

        When that happens to me on Linux, kilall gdbhelps. The MinGW debugger should also be gdb. If you kill this process, you should be fine.

        The interesting question is: Why doesn't the application shut down cleanly?
        The two most popular reasons are:

        • (1) Something inheriting from QObjectis (soft-)leaking, which keeps the event loop spinning after everything else has shut down.
        • (2) Application shutdown calls a slot, that blocks the event loop (e.g. by waiting for something that doesn't happen).

        It's worth to investigate this, e.g. by closing the application and then setting a break point in QGuiApplication::processEvents(). If an event gets delivered to a QObject, you can investigate what it is and why it is still alive.
        If the break point doesn't kick in, application code is blocking it. You have to spill loads of qDebug() << __FUNCTION__ << this << "some info"; in every shutdown step to see where it hangs.

        Software Engineer
        The Qt Company, Oslo

        N 1 Reply Last reply 17 Jan 2024, 20:10
        1
        • A Axel Spoerl
          17 Jan 2024, 18:58

          @nekkceb
          Technically speaking, Windows blocks your binary while being executed in the debugger. That makes sense, you don't want to change horses on the fly.

          When that happens to me on Linux, kilall gdbhelps. The MinGW debugger should also be gdb. If you kill this process, you should be fine.

          The interesting question is: Why doesn't the application shut down cleanly?
          The two most popular reasons are:

          • (1) Something inheriting from QObjectis (soft-)leaking, which keeps the event loop spinning after everything else has shut down.
          • (2) Application shutdown calls a slot, that blocks the event loop (e.g. by waiting for something that doesn't happen).

          It's worth to investigate this, e.g. by closing the application and then setting a break point in QGuiApplication::processEvents(). If an event gets delivered to a QObject, you can investigate what it is and why it is still alive.
          If the break point doesn't kick in, application code is blocking it. You have to spill loads of qDebug() << __FUNCTION__ << this << "some info"; in every shutdown step to see where it hangs.

          N Offline
          N Offline
          nekkceb
          wrote on 17 Jan 2024, 20:10 last edited by
          #3

          @Axel-Spoerl Thanks for the quick response. I dont see any thing unusual in src code that might 'keep spinning' to block the shutdown. Looking at task manager, I do see a gdb.exe and gdborig.exe running, under the heading of QtCreator, but only when my program is running, and these both disappear when I stop it, either from the close 'X' in upper right, or using the QtCreator to stop the debugger.
          When you say to put a breakpoint in
          QGuiApplication::processEvents(),
          I did not install Qt by building from source. Will it work to over-ride QGuiApplication just to create a processEvents I can set a breakpoint in?
          Why was this working fine no more than a few days ago??
          BTW I am modifying one of the examples here. Although I have expanded it a bit, it is still a pretty small project.
          !

          A 1 Reply Last reply 17 Jan 2024, 20:28
          0
          • N nekkceb
            17 Jan 2024, 20:10

            @Axel-Spoerl Thanks for the quick response. I dont see any thing unusual in src code that might 'keep spinning' to block the shutdown. Looking at task manager, I do see a gdb.exe and gdborig.exe running, under the heading of QtCreator, but only when my program is running, and these both disappear when I stop it, either from the close 'X' in upper right, or using the QtCreator to stop the debugger.
            When you say to put a breakpoint in
            QGuiApplication::processEvents(),
            I did not install Qt by building from source. Will it work to over-ride QGuiApplication just to create a processEvents I can set a breakpoint in?
            Why was this working fine no more than a few days ago??
            BTW I am modifying one of the examples here. Although I have expanded it a bit, it is still a pretty small project.
            !

            A Offline
            A Offline
            Axel Spoerl
            Moderators
            wrote on 17 Jan 2024, 20:28 last edited by
            #4

            @nekkceb
            QCoreApplication::processEvents()is not virtual, so you can't override it.
            You can use the Qt Maintenance tool to install Qt with sources and debug symbols. That way you can step into Qt code without having to build it.

            Which example are you using? Just to make sure, that you haven't caught us red-handed ;-)

            Software Engineer
            The Qt Company, Oslo

            N 2 Replies Last reply 18 Jan 2024, 00:08
            0
            • A Axel Spoerl
              17 Jan 2024, 20:28

              @nekkceb
              QCoreApplication::processEvents()is not virtual, so you can't override it.
              You can use the Qt Maintenance tool to install Qt with sources and debug symbols. That way you can step into Qt code without having to build it.

              Which example are you using? Just to make sure, that you haven't caught us red-handed ;-)

              N Offline
              N Offline
              nekkceb
              wrote on 18 Jan 2024, 00:08 last edited by
              #5

              @Axel-Spoerl Thanks I'll try your suggestion. I started with the dynamicspline example for QChart. I am expanding on it considerably to figure out various features of QChart, so it is not likely something in the original source! On the other hand, I dont see how anything I added would cause a background 'run-on' that would prevent the debugger stopping.

              1 Reply Last reply
              0
              • A Axel Spoerl
                17 Jan 2024, 20:28

                @nekkceb
                QCoreApplication::processEvents()is not virtual, so you can't override it.
                You can use the Qt Maintenance tool to install Qt with sources and debug symbols. That way you can step into Qt code without having to build it.

                Which example are you using? Just to make sure, that you haven't caught us red-handed ;-)

                N Offline
                N Offline
                nekkceb
                wrote on 18 Jan 2024, 18:56 last edited by
                #6

                @Axel-Spoerl I hate to say it but this is getting worse. I just re-opened a major project using Qt 5.15.13, and the same thing happens. AND, these are all new developments in the last week. It is as if I stumbled on setting something in QtCreator that I should not have, but I do not recall even looking at preferences recently. I can re-build and run the project initially, but if I try to re-build it, the .exe appears to be locked somehow and I cant delete it, thus getting message from the build system the the file is in use. i have run the Task manager, cant find either gdb or the executable running. I have also run the program 'tasklist' from a cmd window to find it, no avail. The only thing to do is re-boot, which is a pain everytime I want top update the executable.
                I also just ran the Qt Maintenance tool to install with source and debug as you indicate, but I cant find a way to do that with existing installs. Is there a check box or some other way of setting an install option that I am missing?

                A 1 Reply Last reply 18 Jan 2024, 19:23
                0
                • N nekkceb
                  18 Jan 2024, 18:56

                  @Axel-Spoerl I hate to say it but this is getting worse. I just re-opened a major project using Qt 5.15.13, and the same thing happens. AND, these are all new developments in the last week. It is as if I stumbled on setting something in QtCreator that I should not have, but I do not recall even looking at preferences recently. I can re-build and run the project initially, but if I try to re-build it, the .exe appears to be locked somehow and I cant delete it, thus getting message from the build system the the file is in use. i have run the Task manager, cant find either gdb or the executable running. I have also run the program 'tasklist' from a cmd window to find it, no avail. The only thing to do is re-boot, which is a pain everytime I want top update the executable.
                  I also just ran the Qt Maintenance tool to install with source and debug as you indicate, but I cant find a way to do that with existing installs. Is there a check box or some other way of setting an install option that I am missing?

                  A Offline
                  A Offline
                  Axel Spoerl
                  Moderators
                  wrote on 18 Jan 2024, 19:23 last edited by
                  #7

                  @nekkceb
                  86d30d02-ab9d-41c8-aeda-237042f07e8a-image.png

                  Software Engineer
                  The Qt Company, Oslo

                  N 1 Reply Last reply 18 Jan 2024, 20:09
                  1
                  • A Axel Spoerl
                    18 Jan 2024, 19:23

                    @nekkceb
                    86d30d02-ab9d-41c8-aeda-237042f07e8a-image.png

                    N Offline
                    N Offline
                    nekkceb
                    wrote on 18 Jan 2024, 20:09 last edited by
                    #8

                    @Axel-Spoerl Sorry, missed the little drop-down arrows! Seems I already have the debug info.

                    A 1 Reply Last reply 19 Jan 2024, 06:58
                    0
                    • N nekkceb
                      18 Jan 2024, 20:09

                      @Axel-Spoerl Sorry, missed the little drop-down arrows! Seems I already have the debug info.

                      A Offline
                      A Offline
                      Axel Spoerl
                      Moderators
                      wrote on 19 Jan 2024, 06:58 last edited by
                      #9

                      @nekkceb
                      No worries. I am curious to learn what you observe!

                      Software Engineer
                      The Qt Company, Oslo

                      N 2 Replies Last reply 19 Jan 2024, 14:19
                      0
                      • A Axel Spoerl
                        19 Jan 2024, 06:58

                        @nekkceb
                        No worries. I am curious to learn what you observe!

                        N Offline
                        N Offline
                        nekkceb
                        wrote on 19 Jan 2024, 14:19 last edited by
                        #10

                        @Axel-Spoerl Well, I apologize, but I am not expert in debugging compiler issues. I cant see how to do a breakpoint as you suggest, I tried stepping into the .exec function, but that did not do anything. Looks like I am going to have to live with this rather bizarre new behavior or rely on someone more expert to figure it out!

                        1 Reply Last reply
                        0
                        • A Axel Spoerl
                          19 Jan 2024, 06:58

                          @nekkceb
                          No worries. I am curious to learn what you observe!

                          N Offline
                          N Offline
                          nekkceb
                          wrote on 20 Jan 2024, 15:09 last edited by
                          #11

                          @Axel-Spoerl I found a solution that works much better than re-booting the computer between each debug cycle. Turns out opening a cmd-prompt, cd to the directory with the offending .exe file and just enter del <filename>.exe /f does the trick!
                          However, I still wonder why this behavior started all of a sudden about a week ago, no recent updates to either Windows or Qt. I probably fat-fingered a setting somewhere in Qt, but have not been able to find it so far.

                          JonBJ 1 Reply Last reply 20 Jan 2024, 15:32
                          0
                          • N nekkceb
                            20 Jan 2024, 15:09

                            @Axel-Spoerl I found a solution that works much better than re-booting the computer between each debug cycle. Turns out opening a cmd-prompt, cd to the directory with the offending .exe file and just enter del <filename>.exe /f does the trick!
                            However, I still wonder why this behavior started all of a sudden about a week ago, no recent updates to either Windows or Qt. I probably fat-fingered a setting somewhere in Qt, but have not been able to find it so far.

                            JonBJ Online
                            JonBJ Online
                            JonB
                            wrote on 20 Jan 2024, 15:32 last edited by JonB
                            #12

                            @nekkceb
                            Does it require you use the /f option? If so, that forces deleting of read-only file, which (unlike Linux) Windows/cmd does not allow you to do directly, it requires you make it non-read-only first. If the file being created is somehow being marked read-only then it would not surprise me that Creator or whatever does not do this and expects to open the file directly.

                            How that relates to the .exe you are producing I do not know, nor why it has just started happening. But see whether the file is read-only and/or you have to use del /f to delete it, that's a clue.

                            BTW, do you use a virus scanner? It is possible that is looking at generated .exe files, worth switching it off or telling it to ignore the build directory.

                            N 1 Reply Last reply 20 Jan 2024, 19:22
                            0
                            • JonBJ JonB
                              20 Jan 2024, 15:32

                              @nekkceb
                              Does it require you use the /f option? If so, that forces deleting of read-only file, which (unlike Linux) Windows/cmd does not allow you to do directly, it requires you make it non-read-only first. If the file being created is somehow being marked read-only then it would not surprise me that Creator or whatever does not do this and expects to open the file directly.

                              How that relates to the .exe you are producing I do not know, nor why it has just started happening. But see whether the file is read-only and/or you have to use del /f to delete it, that's a clue.

                              BTW, do you use a virus scanner? It is possible that is looking at generated .exe files, worth switching it off or telling it to ignore the build directory.

                              N Offline
                              N Offline
                              nekkceb
                              wrote on 20 Jan 2024, 19:22 last edited by
                              #13

                              @JonB Thanks for the ideas. Turns out the /f option is not needed. But things are certainly strange! If I try to delete the file in the Windows File Explorer, I get this message:
                              276c5ed8-57e4-40ce-b58c-5bd7d887fa9a-image.png
                              Note I tried to do this after stopping the program in the debugger AND closing QtCreator. The file is NOT marked as read-only, though windows thinks it is 'open' somehow. Using the cmd-prompt, just issue a del BIPSMain.exe deletes it and allows me to rebuild it in QtCreator.

                              A JonBJ 2 Replies Last reply 20 Jan 2024, 19:57
                              0
                              • N nekkceb
                                20 Jan 2024, 19:22

                                @JonB Thanks for the ideas. Turns out the /f option is not needed. But things are certainly strange! If I try to delete the file in the Windows File Explorer, I get this message:
                                276c5ed8-57e4-40ce-b58c-5bd7d887fa9a-image.png
                                Note I tried to do this after stopping the program in the debugger AND closing QtCreator. The file is NOT marked as read-only, though windows thinks it is 'open' somehow. Using the cmd-prompt, just issue a del BIPSMain.exe deletes it and allows me to rebuild it in QtCreator.

                                A Offline
                                A Offline
                                Axel Spoerl
                                Moderators
                                wrote on 20 Jan 2024, 19:57 last edited by
                                #14

                                @nekkceb
                                Is BIPS20 your project / BIPSMain.exe your executable?
                                If so: It's in use by gdbor however the MinGW derivate is called.

                                Software Engineer
                                The Qt Company, Oslo

                                N 1 Reply Last reply 20 Jan 2024, 22:09
                                1
                                • N nekkceb
                                  20 Jan 2024, 19:22

                                  @JonB Thanks for the ideas. Turns out the /f option is not needed. But things are certainly strange! If I try to delete the file in the Windows File Explorer, I get this message:
                                  276c5ed8-57e4-40ce-b58c-5bd7d887fa9a-image.png
                                  Note I tried to do this after stopping the program in the debugger AND closing QtCreator. The file is NOT marked as read-only, though windows thinks it is 'open' somehow. Using the cmd-prompt, just issue a del BIPSMain.exe deletes it and allows me to rebuild it in QtCreator.

                                  JonBJ Online
                                  JonBJ Online
                                  JonB
                                  wrote on 20 Jan 2024, 20:47 last edited by JonB
                                  #15

                                  @nekkceb said in error: cannot open output file:

                                  del BIPSMain.exe deletes it and allows me to rebuild it in QtCreator.

                                  (Now that we know /f/read-only is not the issue.) Then you are fortunate. Clearly something has it open in some shape or form, in which case Windows does not normally allow to delete the file. So this is surprising but convenient.

                                  If you really are sure tasklist/taskman cannot find the executable file still running, and you still want to know what is going on, you could download whatever currently works for Windows which allows you to view open handles in the OS. There used to be a procman and/or procexplorer (or similar names) from sysinternals for this, if they don't work I imagine there are alternatives now.

                                  1 Reply Last reply
                                  0
                                  • A Axel Spoerl
                                    20 Jan 2024, 19:57

                                    @nekkceb
                                    Is BIPS20 your project / BIPSMain.exe your executable?
                                    If so: It's in use by gdbor however the MinGW derivate is called.

                                    N Offline
                                    N Offline
                                    nekkceb
                                    wrote on 20 Jan 2024, 22:09 last edited by
                                    #16

                                    @Axel-Spoerl Agree, you have mentioned that before, but neither BIPSMain nor gdb are found in the Task Manager, or (per @JonB suggestion) the procexp64.exe from sysinternals. Both do appear in the TaskManager when the debug session is running, but both go away when the application exits. So, I am truly at a loss, but knowing I can just delete BIPSMain use the del command in a DOS-box helps a lot.

                                    JonBJ 1 Reply Last reply 20 Jan 2024, 22:23
                                    0
                                    • N nekkceb
                                      20 Jan 2024, 22:09

                                      @Axel-Spoerl Agree, you have mentioned that before, but neither BIPSMain nor gdb are found in the Task Manager, or (per @JonB suggestion) the procexp64.exe from sysinternals. Both do appear in the TaskManager when the debug session is running, but both go away when the application exits. So, I am truly at a loss, but knowing I can just delete BIPSMain use the del command in a DOS-box helps a lot.

                                      JonBJ Online
                                      JonBJ Online
                                      JonB
                                      wrote on 20 Jan 2024, 22:23 last edited by
                                      #17

                                      @nekkceb
                                      If you have got procexp64 or similar working, instead of look for executable running it has something which lets you pick a file and find all "open handles" into it. That really ought find dynamicspline.exe with a handle!

                                      Or, from error message

                                      :-1: error: cannot open output file dynamicspline.exe: Invalid argument.

                                      the invalid argument might just indicate that the file "does not exist" or "half exists", is in a funny state so that it cannot be overwritten but can be deleted.... Anyway, that's me out of suggestions now.

                                      1 Reply Last reply
                                      0
                                      • N nekkceb
                                        17 Jan 2024, 17:37

                                        After running my code in debug mode, stop the process and make changes, when I try to rebuild or re-run in the debugger I get this compiler error:
                                        :-1: error: cannot open output file dynamicspline.exe: Invalid argument.
                                        There is an old post related to this, but in that case, it seems they could find the process still running in the task manager. My application is a windows GUI, not a console application, and I do not see any processes related to it in the task manager that I can kill. The only thing that works for me is to exit QTCreator, then find the build directory (e.g. build-dynamicspline-Desktop_Qt_6_2_8_MinGW_64_bit-Debug) and rename it to something like 'jumk'.. I can then re-start Qt-Creator, re-buiuld and ruyn again. But this is a pain to deal with. AND it just started, i was working fine a few days ago!
                                        Windows 10, latest build, Qt Creator 11.0.0, compiling with Desktop Qt 6.2.8 MinGW 64-bit

                                        N Offline
                                        N Offline
                                        nekkceb
                                        wrote on 16 Feb 2024, 17:48 last edited by nekkceb
                                        #18
                                        This post is deleted!
                                        1 Reply Last reply
                                        1
                                        • N nekkceb has marked this topic as solved on 16 Feb 2024, 17:49

                                        • Login

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