Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt Creator and other tools
  4. QtCreator and environment variable in INCLUDEPATH
Forum Updated to NodeBB v4.3 + New Features

QtCreator and environment variable in INCLUDEPATH

Scheduled Pinned Locked Moved Qt Creator and other tools
includepathenvironment varqtcreator
10 Posts 2 Posters 15.3k 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.
  • A Offline
    A Offline
    achard.ju
    wrote on 21 Apr 2016, 14:55 last edited by
    #1

    Hi everyone.

    I am facing a problem while porting my project from Qt 4.7.4/QtCreator 2.6.2 to Qt 4.8.6/QtCreator 3.6.1.
    We are using environment variable a lot, to add path in INCLUDEPATH of our .pro files. We often add multiple path in there environment variables.

    Since I try to use QtCreator 3.6.1, the completion does not work anymore for include that are defined in the INCLUDEPATH using theses environment variable.

    Let's take an exemple :

    I have a test project, with an external class, defined in a .h and .cpp files from a folder /home/myClass.
    I have an environment variable (ENV_VAR) defined to /home/myClass

    In the .pro file of my test project who is stored in /home/myProject I do

    INCLUDEPATH += $$(ENV_VAR)
    

    This works fine. But now, if I put two path in the ENV_VAR (eg: /home/myClass /home/myOtherClass), QtCreator does not resolve the includes anymore and completion does not work either. By the way QMake works, as I can compile the project.
    This works with QtCreator 2.6.2.

    If i do

    INCLUDEPATH += /home/myClass /home/myOtherClass
    

    it works in both QtCreator versions.

    I hope I was clear enough, does anyone have a clue on wath's going on here ?

    Thanks !

    1 Reply Last reply
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 21 Apr 2016, 22:21 last edited by
      #2

      Hi,

      Sounds like it might be a regression. Can you create a minimal sample project that can reproduce this ?

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

      A 1 Reply Last reply 22 Apr 2016, 08:38
      0
      • S SGaist
        21 Apr 2016, 22:21

        Hi,

        Sounds like it might be a regression. Can you create a minimal sample project that can reproduce this ?

        A Offline
        A Offline
        achard.ju
        wrote on 22 Apr 2016, 08:38 last edited by achard.ju
        #3

        @SGaist Yes I can do this :)

        Download File

        You will have to define an environment variable named ENV_VAR to '../myClass' in the project configuration, compilation environment.
        If you do this, you will be able to CTRL+Clic on myClass.h to open the header.

        Now if you add something before or after in the ENV_VAR like :

        ENV_VAR=/this/break/completion ../myClass
        

        or

        ENV_VAR=../myClass /this/break/completion
        

        even if the path is valid, the completion does not work anymore.

        Thanks !

        1 Reply Last reply
        0
        • S Offline
          S Offline
          SGaist
          Lifetime Qt Champion
          wrote on 22 Apr 2016, 21:11 last edited by
          #4

          What I suspect is that the handling of spaces in the environment variable has changed.

          If you write INCLUDEPATH += "/this/break/completion ../myClass", it will also "break".

          I can't comment whether this change can be considered a bug since you would usually quote strings that you put in an environment variable if it contains space(s) and use a separator like : when you want to have several values.

          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
          • A Offline
            A Offline
            achard.ju
            wrote on 23 Apr 2016, 11:37 last edited by
            #5

            My problem is that none of the solutions works, i can't have multiple path in one environment variable.

            Why Creator does not replace the $$(ENV_VAR) whit its content ? Because this will work, and was working in previous version.
            It means that

            INCLUDEPATH = /this/break/completion ../myClass
            

            and

            ENV_VAR=/this/break/completion ../myClass
            INCLUDEPATH = $$(ENV_VAR)
            

            does not behave the same way.
            For me it's a problem, and i can't find a workaround to bypass this !

            Nota :
            If i use a variable in the pro file instead of an environment variable it works... Like :

            TEST_VAR = /this/break/completion ../myClass
            INCLUDEPATH = $${TEST_VAR}
            
            1 Reply Last reply
            0
            • S Offline
              S Offline
              SGaist
              Lifetime Qt Champion
              wrote on 24 Apr 2016, 20:04 last edited by SGaist
              #6

              It's not Qt Creator, it's qmake. Anyway, I suspect that the content is quoted now.

              Try with:

              for (var, $ $list($ $(ENV_VAR))) {
                  INCLUDEPATH += $ $var
              }
              

              [edit: fixed code sample, remove spaces between $ in real .pro file]

              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
              1
              • A Offline
                A Offline
                achard.ju
                wrote on 25 Apr 2016, 07:39 last edited by
                #7

                I can't get this to work either. :(

                By the way how can it be QMake and not QtCreator as the compilation work, only the completion in IDE does not work.

                1 Reply Last reply
                0
                • S Offline
                  S Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on 25 Apr 2016, 20:36 last edited by
                  #8

                  For qmake, i was referencing the environment variable handling.

                  Note that I forgot the double $ problem. I've fixed the sample, can you retry with that new version ? It's working correctly on Qt Creator 3.5.1

                  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
                  1
                  • A Offline
                    A Offline
                    achard.ju
                    wrote on 26 Apr 2016, 07:26 last edited by
                    #9

                    Okay this works.

                    It's not an elegant solution for us, as we have a lot of pro file, with a lot on environment variable used in INCLUDEPATH in these. It's sad that this particular behaviour has changed in new versions. We will figure out how to make things works for us.

                    Thanks a lot for your help !

                    1 Reply Last reply
                    0
                    • S Offline
                      S Offline
                      SGaist
                      Lifetime Qt Champion
                      wrote on 26 Apr 2016, 07:35 last edited by
                      #10

                      One alternative would be to create your own function that does that parsing and use it like:

                      INCLUDEPATH += $ $parseEnvVariable(ENV_VAR)
                      

                      That way if you change the formatting of your environment variables you only have to update the code in one place.

                      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

                      4/10

                      22 Apr 2016, 21:11

                      • Login

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