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

  • 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

  • "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.

  • Hi,

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


  • 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"@

  • 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.

  • 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")@


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

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

  • 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.

  • 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.

  • 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)


    Pass information to Qmake (lib path)


Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.