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. In ubuntu,how to use qt to compile and debug a programme needing environment variables
QtWS25 Last Chance

In ubuntu,how to use qt to compile and debug a programme needing environment variables

Scheduled Pinned Locked Moved Unsolved General and Desktop
5 Posts 4 Posters 1.1k 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.
  • Y Offline
    Y Offline
    yicong liu
    wrote on last edited by
    #1

    My English is not so good.At first, I use cmake and terminal to compile a programme needing environment variables. In this way, I always enter a command "source ......sh" to set my environment variables. Now, I need to use qt to debug my programme. However, I don't know how to set environment variables in qt. I'll appreciate your help, thank you!

    1 Reply Last reply
    0
    • F Offline
      F Offline
      fbaqt
      wrote on last edited by
      #2

      The environment variables for any program are inherited from the shell that starts the app. Since Qt creator is starting the app, you will inherit environment variables that Qt inherited. So, you would want to open a shell, set your environment variables, then start QtCreator from that shell. Then, when you run your app from QtCreator, the environment variables you need should be there.

      The other option would be to add some code to your main.cpp to set the environment variables while you are testing, or add some other method to your code to fake the correct environment variables.

      Hope this helps!

      P.S. Your English is actually pretty good!

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

        Hi and welcome to devnet,

        If you are using Qt Creator, you can go on the Run part of the Project panel. There you can add/remove/modify environment variables as needed for testing 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

        1 Reply Last reply
        0
        • F fbaqt

          The environment variables for any program are inherited from the shell that starts the app. Since Qt creator is starting the app, you will inherit environment variables that Qt inherited. So, you would want to open a shell, set your environment variables, then start QtCreator from that shell. Then, when you run your app from QtCreator, the environment variables you need should be there.

          The other option would be to add some code to your main.cpp to set the environment variables while you are testing, or add some other method to your code to fake the correct environment variables.

          Hope this helps!

          P.S. Your English is actually pretty good!

          Y Offline
          Y Offline
          yicong liu
          wrote on last edited by
          #4

          @fbaqt thanks, I do it through run qt in terminal.

          jsulmJ 1 Reply Last reply
          0
          • Y yicong liu

            @fbaqt thanks, I do it through run qt in terminal.

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

            @yicong-liu Then set needed variables in the same terminal before starting your application

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

            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