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. Run environment in Qt Creator
Forum Updated to NodeBB v4.3 + New Features

Run environment in Qt Creator

Scheduled Pinned Locked Moved Unsolved General and Desktop
26 Posts 5 Posters 6.5k Views 1 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.
  • JonBJ JonB

    @gibbogle
    If it "crashes". start it off with debugging from Qt Creator (I don't use it, for "green arrow" there will be one which is just "Run" and another which is "Debug Run" or similar) and you will get a stack trace of where it crashes. If not, something else is happening.

    G Offline
    G Offline
    gibbogle
    wrote on last edited by gibbogle
    #3

    @jonb My question mainly concerns the run environments. What makes the one used in Qt Creator different from the system environment used in a terminal?
    Running in debugging mode gives a popup "The inferior stopped because it received a signal from the operating system: SIGSEGV. I also get 24 lines of assembler code, which convey nothing to me.

    JonBJ 1 Reply Last reply
    0
    • G gibbogle

      @jonb My question mainly concerns the run environments. What makes the one used in Qt Creator different from the system environment used in a terminal?
      Running in debugging mode gives a popup "The inferior stopped because it received a signal from the operating system: SIGSEGV. I also get 24 lines of assembler code, which convey nothing to me.

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by JonB
      #4

      @gibbogle
      SISSEGV, IIRC, means a null, or possibly out-of-bounds, pointer dereference, somewhere. Not sure exactly what you mean by "I also get 24 lines of assembler code", I would have hoped that if you look at the stacktrace (e.g. gdb command bt) you would get a few non-assembler frames at the top, but maybe not.

      If you put a breakpoint on the very first line of your main(), do you even get there? If you do it's somewhere in the code, and you can at least step around and see what it does in. But if you do not even hit that then it implies during internal run-time start-up, and you have a deeper problem..

      (Assuming you build for debug/non-debug similarly when you run inside or outside Creator.) The only difference between the Creator System/Build environments and the terminal environment, apart from working directory, should be environment variables. You can view what Creator is passing from the environment variables it shows, and compare that against the terminal environment via env | sort, or similar. You could also try running your program from the terminal through gdb your-executable to test the debug situation outside of Creator.

      If you're still stuck. Under Linux you can run an executable via strace executable [args]. This produces tracing output showing every system call being made. In the "crash" case, the last few lines may give you a clue where your program is getting to just before it dies. Now, as I said I don't use Creator, but hopefully where the "command line" is for running your program you can change that to strace your-executable to try?

      One other thought: if you say outside Creator "it just sits there until I hit ctrl-C." that means the process (still) has a controlling terminal. When you run it from Creator I think it does not --- doesn't Creator have an option checkbox when launching/debugging programs to say "create a (new) terminal when running this"? It might be worth switching that on to see whether that makes any differnce.

      These are my thoughts :)

      G 2 Replies Last reply
      2
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by
        #5

        Hi,

        To add to @JonB, Qt Creator modifies the PATH, (DY)LD_LIBRARY_PATH or DYLD_FRAMEWORK_PATH environnement variables, depending on the OS, in order for your application to find the Qt version of the Kit you are using to build it.

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

        G 1 Reply Last reply
        1
        • JonBJ JonB

          @gibbogle
          SISSEGV, IIRC, means a null, or possibly out-of-bounds, pointer dereference, somewhere. Not sure exactly what you mean by "I also get 24 lines of assembler code", I would have hoped that if you look at the stacktrace (e.g. gdb command bt) you would get a few non-assembler frames at the top, but maybe not.

          If you put a breakpoint on the very first line of your main(), do you even get there? If you do it's somewhere in the code, and you can at least step around and see what it does in. But if you do not even hit that then it implies during internal run-time start-up, and you have a deeper problem..

          (Assuming you build for debug/non-debug similarly when you run inside or outside Creator.) The only difference between the Creator System/Build environments and the terminal environment, apart from working directory, should be environment variables. You can view what Creator is passing from the environment variables it shows, and compare that against the terminal environment via env | sort, or similar. You could also try running your program from the terminal through gdb your-executable to test the debug situation outside of Creator.

          If you're still stuck. Under Linux you can run an executable via strace executable [args]. This produces tracing output showing every system call being made. In the "crash" case, the last few lines may give you a clue where your program is getting to just before it dies. Now, as I said I don't use Creator, but hopefully where the "command line" is for running your program you can change that to strace your-executable to try?

          One other thought: if you say outside Creator "it just sits there until I hit ctrl-C." that means the process (still) has a controlling terminal. When you run it from Creator I think it does not --- doesn't Creator have an option checkbox when launching/debugging programs to say "create a (new) terminal when running this"? It might be worth switching that on to see whether that makes any differnce.

          These are my thoughts :)

          G Offline
          G Offline
          gibbogle
          wrote on last edited by
          #6

          @jonb Thanks for all your helpful suggestions, I am starting to explore them.

          1 Reply Last reply
          0
          • JonBJ JonB

            @gibbogle
            SISSEGV, IIRC, means a null, or possibly out-of-bounds, pointer dereference, somewhere. Not sure exactly what you mean by "I also get 24 lines of assembler code", I would have hoped that if you look at the stacktrace (e.g. gdb command bt) you would get a few non-assembler frames at the top, but maybe not.

            If you put a breakpoint on the very first line of your main(), do you even get there? If you do it's somewhere in the code, and you can at least step around and see what it does in. But if you do not even hit that then it implies during internal run-time start-up, and you have a deeper problem..

            (Assuming you build for debug/non-debug similarly when you run inside or outside Creator.) The only difference between the Creator System/Build environments and the terminal environment, apart from working directory, should be environment variables. You can view what Creator is passing from the environment variables it shows, and compare that against the terminal environment via env | sort, or similar. You could also try running your program from the terminal through gdb your-executable to test the debug situation outside of Creator.

            If you're still stuck. Under Linux you can run an executable via strace executable [args]. This produces tracing output showing every system call being made. In the "crash" case, the last few lines may give you a clue where your program is getting to just before it dies. Now, as I said I don't use Creator, but hopefully where the "command line" is for running your program you can change that to strace your-executable to try?

            One other thought: if you say outside Creator "it just sits there until I hit ctrl-C." that means the process (still) has a controlling terminal. When you run it from Creator I think it does not --- doesn't Creator have an option checkbox when launching/debugging programs to say "create a (new) terminal when running this"? It might be worth switching that on to see whether that makes any differnce.

            These are my thoughts :)

            G Offline
            G Offline
            gibbogle
            wrote on last edited by gibbogle
            #7

            @jonb There doesn't seem to be a way to change the command line in Qt Creator, you can only supply arguments.
            With a breakpoint at the first line in main(), the execution doesn't reach there. The Disassembler screen shows 24 lines of assembler, but the green arrow (presumably indicating the failure point) is on the 6th line (the last here):
            0x7fffee371fda 00 00 add %al,(%rax)
            0x7fffee371fdc 00 00 add %al,(%rax)
            0x7fffee371fde 66 90 xchg %ax,%ax
            0x7fffee371fe0 48 8b 05 21 0f b2 00 mov 0xb20f21(%rip),%rax # 0x7fffeee92f08
            0x7fffee371fe7 48 89 05 ba 6b b3 00 mov %rax,0xb36bba(%rip) # 0x7fffeeea8ba8
            0x7fffee371fee f0 ff 00 lock incl (%rax)

            I have tried ticking the "Run in terminal" box, but that had no effect.
            A couple of the linked libraries are Release, not Debug, but I don't know if that could cause this crash - anyway, it doesn't when I run the program outside Qt Creator.

            1 Reply Last reply
            0
            • SGaistS SGaist

              Hi,

              To add to @JonB, Qt Creator modifies the PATH, (DY)LD_LIBRARY_PATH or DYLD_FRAMEWORK_PATH environnement variables, depending on the OS, in order for your application to find the Qt version of the Kit you are using to build it.

              G Offline
              G Offline
              gibbogle
              wrote on last edited by
              #8

              @sgaist I gathered that something of the sort was being done. I'm not sure how to see exactly what PATH and LD_LIBRARY_PATH are being used, but I also can't see why some inconsistency there would cause this segment violation error.

              aha_1980A 1 Reply Last reply
              0
              • G gibbogle

                @sgaist I gathered that something of the sort was being done. I'm not sure how to see exactly what PATH and LD_LIBRARY_PATH are being used, but I also can't see why some inconsistency there would cause this segment violation error.

                aha_1980A Offline
                aha_1980A Offline
                aha_1980
                Lifetime Qt Champion
                wrote on last edited by
                #9

                @gibbogle

                A couple of the linked libraries are Release, not Debug, but I don't know if that could cause this crash

                On Linux: no, on Windows: indeed.

                But for all platforms, you cannot mix Qt libraries of different versions.

                So if, for example, your LD_LIBRARY_PATH contains one Qt version, and you want to run against another version in Creator (which adds the other Qt version to LD_LIBRARY_PATH too), you might encounter strange things.

                Newer Creator versions let you open a terminal with run environment set up, you can use that for further investigation.

                Regards

                Qt has to stay free or it will die.

                G 1 Reply Last reply
                2
                • aha_1980A aha_1980

                  @gibbogle

                  A couple of the linked libraries are Release, not Debug, but I don't know if that could cause this crash

                  On Linux: no, on Windows: indeed.

                  But for all platforms, you cannot mix Qt libraries of different versions.

                  So if, for example, your LD_LIBRARY_PATH contains one Qt version, and you want to run against another version in Creator (which adds the other Qt version to LD_LIBRARY_PATH too), you might encounter strange things.

                  Newer Creator versions let you open a terminal with run environment set up, you can use that for further investigation.

                  Regards

                  G Offline
                  G Offline
                  gibbogle
                  wrote on last edited by
                  #10

                  @aha_1980 I'm running a pretty recent version of Creator, 4.9.1, but I can't see how to open a terminal with run environment set up. I do see the checkbox for 'Run in terminal', and there is a field 'Run configuration', which currently holds the name of the executable. Is that related to what you have mentioned? Can you give me some pointers?

                  I don't have another Qt version in LD_LIBRARY_PATH.

                  Thanks

                  aha_1980A 1 Reply Last reply
                  0
                  • G gibbogle

                    @aha_1980 I'm running a pretty recent version of Creator, 4.9.1, but I can't see how to open a terminal with run environment set up. I do see the checkbox for 'Run in terminal', and there is a field 'Run configuration', which currently holds the name of the executable. Is that related to what you have mentioned? Can you give me some pointers?

                    I don't have another Qt version in LD_LIBRARY_PATH.

                    Thanks

                    aha_1980A Offline
                    aha_1980A Offline
                    aha_1980
                    Lifetime Qt Champion
                    wrote on last edited by
                    #11

                    @gibbogle

                    In Creator 4.10 it's here:

                    0_1568619918779_f46311d7-c0e4-47c3-a326-e0f6356d647a-image.png

                    It may look a bit different in 4.9, but the Projects context menu on a file contains that entry.

                    Regards

                    Qt has to stay free or it will die.

                    G 1 Reply Last reply
                    3
                    • aha_1980A aha_1980

                      @gibbogle

                      In Creator 4.10 it's here:

                      0_1568619918779_f46311d7-c0e4-47c3-a326-e0f6356d647a-image.png

                      It may look a bit different in 4.9, but the Projects context menu on a file contains that entry.

                      Regards

                      G Offline
                      G Offline
                      gibbogle
                      wrote on last edited by
                      #12

                      @aha_1980
                      When I open a terminal with any one of the three environment options (Build, System, Run) and execute the program at the command line, it doesn't crash. It seems that for the purposes of running my program the three environments are all equivalent. When it is invoked by one of the green arrows in Creator, it crashes.

                      aha_1980A 1 Reply Last reply
                      0
                      • G gibbogle

                        @aha_1980
                        When I open a terminal with any one of the three environment options (Build, System, Run) and execute the program at the command line, it doesn't crash. It seems that for the purposes of running my program the three environments are all equivalent. When it is invoked by one of the green arrows in Creator, it crashes.

                        aha_1980A Offline
                        aha_1980A Offline
                        aha_1980
                        Lifetime Qt Champion
                        wrote on last edited by
                        #13

                        @gibbogle said in Run environment in Qt Creator:

                        @aha_1980
                        When I open a terminal with any one of the three environment options (Build, System, Run) and execute the program at the command line, it doesn't crash. It seems that for the purposes of running my program the three environments are all equivalent. When it is invoked by one of the green arrows in Creator, it crashes.

                        Ok, so we still have no solution for your problem, but we know that the environment is unguilty.

                        Does that also happen if you create a "Hello World" example with the wizards?

                        And coming back to @JonB's strace: you can create a custom run configuration (Project > Build & Run > Run > Run configuration > Add > Custom) and see which output you get, hopefully that gives some insight?

                        Regards

                        Qt has to stay free or it will die.

                        G 1 Reply Last reply
                        2
                        • aha_1980A aha_1980

                          @gibbogle said in Run environment in Qt Creator:

                          @aha_1980
                          When I open a terminal with any one of the three environment options (Build, System, Run) and execute the program at the command line, it doesn't crash. It seems that for the purposes of running my program the three environments are all equivalent. When it is invoked by one of the green arrows in Creator, it crashes.

                          Ok, so we still have no solution for your problem, but we know that the environment is unguilty.

                          Does that also happen if you create a "Hello World" example with the wizards?

                          And coming back to @JonB's strace: you can create a custom run configuration (Project > Build & Run > Run > Run configuration > Add > Custom) and see which output you get, hopefully that gives some insight?

                          Regards

                          G Offline
                          G Offline
                          gibbogle
                          wrote on last edited by
                          #14

                          @aha_1980
                          I am able to build and run the examples, and also an application to test Qt3d functionality that I made from a couple of the examples.

                          I set up a custom run configuration (thanks for explaining that), but when I run it, a couple of 'Permission denied' errors are generated, one apparently from execve, the other from fstat (unfortunately it does not seem to be possible to copy-and-paste from the terminal), so strace "exited with 1".

                          aha_1980A jsulmJ 2 Replies Last reply
                          0
                          • G gibbogle

                            @aha_1980
                            I am able to build and run the examples, and also an application to test Qt3d functionality that I made from a couple of the examples.

                            I set up a custom run configuration (thanks for explaining that), but when I run it, a couple of 'Permission denied' errors are generated, one apparently from execve, the other from fstat (unfortunately it does not seem to be possible to copy-and-paste from the terminal), so strace "exited with 1".

                            aha_1980A Offline
                            aha_1980A Offline
                            aha_1980
                            Lifetime Qt Champion
                            wrote on last edited by
                            #15

                            @gibbogle ok, so if the examples work, it must be your project.

                            Have you already wiped the build folder and .pro.user and rebuild your project?

                            Are you linking external libs?

                            Regards

                            Qt has to stay free or it will die.

                            G 1 Reply Last reply
                            0
                            • G gibbogle

                              @aha_1980
                              I am able to build and run the examples, and also an application to test Qt3d functionality that I made from a couple of the examples.

                              I set up a custom run configuration (thanks for explaining that), but when I run it, a couple of 'Permission denied' errors are generated, one apparently from execve, the other from fstat (unfortunately it does not seem to be possible to copy-and-paste from the terminal), so strace "exited with 1".

                              jsulmJ Offline
                              jsulmJ Offline
                              jsulm
                              Lifetime Qt Champion
                              wrote on last edited by
                              #16

                              @gibbogle said in Run environment in Qt Creator:

                              it does not seem to be possible to copy-and-paste from the terminal

                              It is possible: mark text in terminal and press Ctrl-Shift-c to copy (to paste into terminal use Ctrl-Shift-v). Or use context menu of your terminal.

                              https://forum.qt.io/topic/113070/qt-code-of-conduct

                              G 1 Reply Last reply
                              1
                              • aha_1980A aha_1980

                                @gibbogle ok, so if the examples work, it must be your project.

                                Have you already wiped the build folder and .pro.user and rebuild your project?

                                Are you linking external libs?

                                Regards

                                G Offline
                                G Offline
                                gibbogle
                                wrote on last edited by
                                #17

                                @aha_1980
                                Yes, I just again wiped the build folder and .pro.user and rebuilt. No change.
                                Yes, I am linking external libs.

                                The program runs (Debug and Release) in a terminal.

                                1 Reply Last reply
                                0
                                • jsulmJ jsulm

                                  @gibbogle said in Run environment in Qt Creator:

                                  it does not seem to be possible to copy-and-paste from the terminal

                                  It is possible: mark text in terminal and press Ctrl-Shift-c to copy (to paste into terminal use Ctrl-Shift-v). Or use context menu of your terminal.

                                  G Offline
                                  G Offline
                                  gibbogle
                                  wrote on last edited by
                                  #18

                                  @jsulm
                                  When I do Ctrl-Shift-c all that happens is a ^C is displayed.
                                  I'm not sure what the context menu of the terminal is. If I right-click at the top I just get Minimize, Maximize, Move etc.

                                  jsulmJ 1 Reply Last reply
                                  0
                                  • G gibbogle

                                    @jsulm
                                    When I do Ctrl-Shift-c all that happens is a ^C is displayed.
                                    I'm not sure what the context menu of the terminal is. If I right-click at the top I just get Minimize, Maximize, Move etc.

                                    jsulmJ Offline
                                    jsulmJ Offline
                                    jsulm
                                    Lifetime Qt Champion
                                    wrote on last edited by
                                    #19

                                    @gibbogle said in Run environment in Qt Creator:

                                    If I right-click at the top I just get Minimize

                                    not at the top, but inside the terminal.

                                    https://forum.qt.io/topic/113070/qt-code-of-conduct

                                    G 1 Reply Last reply
                                    1
                                    • jsulmJ jsulm

                                      @gibbogle said in Run environment in Qt Creator:

                                      If I right-click at the top I just get Minimize

                                      not at the top, but inside the terminal.

                                      G Offline
                                      G Offline
                                      gibbogle
                                      wrote on last edited by
                                      #20

                                      @jsulm
                                      Sorry, I'm still not with you, right-click inside the terminal just highlights text. Is it possible that I have a different terminal program from your one? In the list of Applications on Ubuntu 18.04 I see XTerm and UXTerm. They both behave the same way. Do they need to be configured to have the behaviour you describe?

                                      jsulmJ 1 Reply Last reply
                                      0
                                      • G gibbogle

                                        @jsulm
                                        Sorry, I'm still not with you, right-click inside the terminal just highlights text. Is it possible that I have a different terminal program from your one? In the list of Applications on Ubuntu 18.04 I see XTerm and UXTerm. They both behave the same way. Do they need to be configured to have the behaviour you describe?

                                        jsulmJ Offline
                                        jsulmJ Offline
                                        jsulm
                                        Lifetime Qt Champion
                                        wrote on last edited by
                                        #21

                                        @gibbogle XTerm and UXTerm are not the standard terminals on default Ubuntu installation. You should try the one Ubuntu provides by default (I think it's the one from Gnome).

                                        https://forum.qt.io/topic/113070/qt-code-of-conduct

                                        G 1 Reply Last reply
                                        2
                                        • jsulmJ jsulm

                                          @gibbogle XTerm and UXTerm are not the standard terminals on default Ubuntu installation. You should try the one Ubuntu provides by default (I think it's the one from Gnome).

                                          G Offline
                                          G Offline
                                          gibbogle
                                          wrote on last edited by gibbogle
                                          #22

                                          @jsulm
                                          I'll have a look around, but these are the only ones that Ubuntu 18.04 shows in the list of installed apps (by clicking on the 3x3-dot-grid icon.) There are odd things about this version, e.g. I installed gedit, but it doesn't show up in the list.

                                          Edit: I had to install gnome-terminal, and I see that it provides some useful features.

                                          1 Reply Last reply
                                          1

                                          • Login

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