November 14, 2010

DAXaholic DAXaholic
Lab Rat
3 posts

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
DAXaholic

8 replies

November 15, 2010

Franzk Franzk
Lab Rat
830 posts

Undocumented QMake [qtcentre.org] says the following:

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.

 Signature 

“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

November 15, 2010

DAXaholic DAXaholic
Lab Rat
3 posts

Hi,

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

DAXaholic

November 16, 2010

Franzk Franzk
Lab Rat
830 posts

Hmm, with spaces putting quotes around it worked for me.

  1. LIBS += "C:\\Program Files (x86)\\NVIDIA GPU Computing Toolkit\\CUDA\\v3.2\\lib\\Win32\\cuda.lib"

 Signature 

“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

November 16, 2010

DAXaholic DAXaholic
Lab Rat
3 posts

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.

November 17, 2010

Franzk Franzk
Lab Rat
830 posts

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

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

or

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

 Signature 

“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

November 18, 2010

DAXaholic DAXaholic
Lab Rat
3 posts

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

July 21, 2011

ryocchin ryocchin
Lab Rat
5 posts

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.

October 29, 2011

ZapB ZapB
Robot Herder
1356 posts

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.

 Signature 

Nokia Certified Qt Specialist
Interested in hearing about Qt related work

 
  ‹‹ QLayout Border      Ribbon control ››

You must log in to post a reply. Not a member yet? Register here!