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. Problems with $$quote(...) when used with environment variable
Qt 6.11 is out! See what's new in the release blog

Problems with $$quote(...) when used with environment variable

Scheduled Pinned Locked Moved General and Desktop
10 Posts 5 Posters 12.9k 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.
  • ? Offline
    ? Offline
    A Former User
    wrote on last edited by
    #1

    Hi at all,

    I'm playing a little bit with CUDA.
    Fortunately, there exists a predefined environment variable called 'CUDA_LIB_PATH' which points to the folder with the needed library.
    In my case the value of this env. var. is 'C:\Program Files (x86)\NVIDIA GPU Computing Toolkit\CUDA\v3.2\lib\Win32', thus I have to use the $$quote(...) function due to the whitespaces in it.

    So I wrote the following line to my project file (cuda.lib is the needed library):
    LIBS += $$quote($(CUDA_LIB_PATH)\cuda.lib)
    But this doesn't work, the linker still gets the whitespace separated parts of the string (C:\Program, Files, etc...).

    However, if I write the value of the env. var. directly into the project file it works:
    LIBS += $$quote(C:\Program Files (x86)\NVIDIA GPU Computing Toolkit\CUDA\v3.2\lib\Win32\cuda.lib)

    Also there is an env. var. for the include files called 'CUDA_INC_PATH'.
    In this case the following statement works:
    INCLUDEPATH += $$quote($(CUDA_INC_PATH))

    It is a little bit strange, 'cause for INCLUDEPATH it works but not for LIBS.
    Perhaps someone can help me.

    Thanks in advance
    DAXaholic

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

      "Undocumented QMake":http://www.qtcentre.org/wiki/index.php?title=Undocumented_qmake says the following:

      bq. escape_expand(string) — Does what quote() probably should have done originally, it replaces \, \n, \t, and \r with backslash, newline, tab, and carriage return respectively.

      "Horse sense is the thing a horse has which keeps it from betting on people." -- W.C. Fields

      http://www.catb.org/~esr/faqs/smart-questions.html

      1 Reply Last reply
      0
      • ? Offline
        ? Offline
        A Former User
        wrote on last edited by
        #3

        Hi,

        thank you for your answer.
        But unfortunately it doesn't change anything :'-(

        DAXaholic

        1 Reply Last reply
        0
        • F Offline
          F Offline
          Franzk
          wrote on last edited by
          #4

          Hmm, with spaces putting quotes around it worked for me.
          @LIBS += "C:\Program Files (x86)\NVIDIA GPU Computing Toolkit\CUDA\v3.2\lib\Win32\cuda.lib"@

          "Horse sense is the thing a horse has which keeps it from betting on people." -- W.C. Fields

          http://www.catb.org/~esr/faqs/smart-questions.html

          1 Reply Last reply
          0
          • ? Offline
            ? Offline
            A Former User
            wrote on last edited by
            #5

            Yes, writing the path directly into the project file works for me too. But not when using the environment variable. I'm able to use CUDA by defining the path "hard-coded" but it's not really cute.

            1 Reply Last reply
            0
            • F Offline
              F Offline
              Franzk
              wrote on last edited by
              #6

              I don't have any stuff in paths with spaces, so I'm just guessing. How about this?

              @LIBS += $$quote("$(CUDA_LIB_PATH)\cuda.lib")@

              or

              @LIBS += "$(CUDA_LIB_PATH)\cuda.lib"@

              "Horse sense is the thing a horse has which keeps it from betting on people." -- W.C. Fields

              http://www.catb.org/~esr/faqs/smart-questions.html

              1 Reply Last reply
              0
              • ? Offline
                ? Offline
                A Former User
                wrote on last edited by
                #7

                Sorry, but it seems to be jinxed. The linker still sees the path splitted by spaces.
                However, thank you very much for the effort.

                1 Reply Last reply
                0
                • ? Offline
                  ? Offline
                  A Former User
                  wrote on last edited by
                  #8

                  Hi, I am having the same issue here.
                  On my PC, a path to the NVidia's SDK is set as

                  NVSDKCOMPUTE_ROOT=C:\ProgramData\NVIDIA Corporation\NVIDIA GPU Computing SDK 4.0

                  In my project file , using this environmental variable, I set paths as

                  win32:INCLUDEPATH += $$quote($(NVSDKCOMPUTE_ROOT)/C/common/inc)
                  win32:LIBS += -L$$quote($(NVSDKCOMPUTE_ROOT)/C/common/lib/x64)

                  While the first line seems to work fine, the second line causes error and shows this message, at the end of the compilation....

                  Generating Code...
                  link /LIBPATH:"c:\Qt\4.7.3\lib" /NOLOGO /DEBUG /DLL /MANIFEST /MANIFESTFILE:"debug\mylib.intermediate.manifest" /OUT:..\QtProjects\debug\mylib.dll @C:\Users\user\AppData\Local\Temp\mylib.dll.1908.28782.jom
                  LINK : fatal error LNK1104: cannot open file 'Corporation\NVIDIA.obj'

                  The program compiles and runs fine if the path is hard-coded as

                  LIBS += -L"C:\ProgramData\NVIDIA Corporation\NVIDIA GPU Computing SDK 4.0\C\common\lib\x64"

                  I have a feeling that there is a problem in interpreting the environmental variables with spaces. It is very awkward if I have to modify my project files every time NVidia releases a new SDK. I hope this issue is sorted out in the future release of Qt.

                  Thank you.

                  1 Reply Last reply
                  0
                  • ? Offline
                    ? Offline
                    A Former User
                    wrote on last edited by
                    #9

                    I would be tempted to use an NTFS junction to provide a path without any spaces in it. Qmake and build tools do not always play nicely with spaces so best to avoid them.

                    1 Reply Last reply
                    0
                    • ? Offline
                      ? Offline
                      A Former User
                      wrote on last edited by
                      #10

                      Well, I have the same issue with ITK. My .pro file is slightly different, I use an environment variable which defines a path with a space (still Program Files...), but I use intermediate variables. I haven't solved it for now and will install ITK to a folder without spaces rather than looking for correct syntax. However it would be great to get help.

                      Here is what I came up so far, but it's not right.

                      @# ITK base directory : C:\Program Files\ITK
                      ITK = "$(ITK)"

                      ITK headers base directory

                      ITK_INCLUDES = "$${ITK}/include/ITK4-5"

                      ITK libs base directory

                      ITK_LIBS = "$${ITK}/lib"

                      Pass information to Qmake (include path)

                      INCLUDEPATH +=
                      $$quote($${ITK_INCLUDES})

                      Pass information to Qmake (lib path)

                      QMAKE_LIBDIR +=
                      $$quote($${ITK_LIBS})
                      @

                      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