www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Adding linker paths with spaces using dmd and msvc toolchain

reply Jeremy DeHaan <dehaan.jeremiah gmail.com> writes:
I have a path to where some .libs are, and this path has some 
spaces in it. Using dmd and the msvc toolchain, I only seem to be 
able to correctly link .lib files if I pass them to the compiler 
with their full paths, or if I give the linker a relative path.

When I add -L/LIBPATH:"path" to the command line, it ends up 
looking like this:
-L/LIBPATH:"C:\Users\Jeremy DeHaan\Desktop\CODE\dsfml\lib".

The linker will complain that it cannot open input file 
'DeHaan\Desktop\CODE\dsfml\lib.obj'.

How does one correctly add a linker path that has spaces?
Dec 29 2016
parent reply Jerry <hurricane hereiam.com> writes:
On Friday, 30 December 2016 at 03:51:13 UTC, Jeremy DeHaan wrote:
 I have a path to where some .libs are, and this path has some 
 spaces in it. Using dmd and the msvc toolchain, I only seem to 
 be able to correctly link .lib files if I pass them to the 
 compiler with their full paths, or if I give the linker a 
 relative path.

 When I add -L/LIBPATH:"path" to the command line, it ends up 
 looking like this:
 -L/LIBPATH:"C:\Users\Jeremy DeHaan\Desktop\CODE\dsfml\lib".

 The linker will complain that it cannot open input file 
 'DeHaan\Desktop\CODE\dsfml\lib.obj'.

 How does one correctly add a linker path that has spaces?
The quotes get consumed by the command line. The way DMD spawns the linker by creating a new string with all the flags. So it smashes everything into a new string, ignoring how the string was passed into DMD. I think you can use triple quotes, """string with space""", and it should make the string passed to DMD include the string. Might be different for powershell.
Dec 29 2016
next sibling parent reply Jeremy DeHaan <dehaan.jeremiah gmail.com> writes:
On Friday, 30 December 2016 at 04:56:59 UTC, Jerry wrote:
 On Friday, 30 December 2016 at 03:51:13 UTC, Jeremy DeHaan 
 wrote:
 How does one correctly add a linker path that has spaces?
The quotes get consumed by the command line. The way DMD spawns the linker by creating a new string with all the flags. So it smashes everything into a new string, ignoring how the string was passed into DMD. I think you can use triple quotes, """string with space""", and it should make the string passed to DMD include the string. Might be different for powershell.
You mean I could do -L/LIBPATH:"""path"""?
Dec 29 2016
next sibling parent Ivan Kazmenko <gassa mail.ru> writes:
On Friday, 30 December 2016 at 05:24:56 UTC, Jeremy DeHaan wrote:
 On Friday, 30 December 2016 at 04:56:59 UTC, Jerry wrote:
 On Friday, 30 December 2016 at 03:51:13 UTC, Jeremy DeHaan 
 wrote:
 How does one correctly add a linker path that has spaces?
The quotes get consumed by the command line. The way DMD spawns the linker by creating a new string with all the flags. So it smashes everything into a new string, ignoring how the string was passed into DMD. I think you can use triple quotes, """string with space""", and it should make the string passed to DMD include the string. Might be different for powershell.
You mean I could do -L/LIBPATH:"""path"""?
There is also the dark and dirty way of using the short DOS path, which is still maintained on Windows file system partitions. How to get DOS path: http://stackoverflow.com/questions/4051088/how-to-get-dos-path-instead-of-windows-path I can't recommend it as a long-term solution, but it sure can help when one needs things working here and now. Ivan Kazmenko.
Dec 30 2016
prev sibling next sibling parent Jerry <hurricane hereiam.com> writes:
On Friday, 30 December 2016 at 05:24:56 UTC, Jeremy DeHaan wrote:
 On Friday, 30 December 2016 at 04:56:59 UTC, Jerry wrote:
 On Friday, 30 December 2016 at 03:51:13 UTC, Jeremy DeHaan 
 wrote:
 How does one correctly add a linker path that has spaces?
The quotes get consumed by the command line. The way DMD spawns the linker by creating a new string with all the flags. So it smashes everything into a new string, ignoring how the string was passed into DMD. I think you can use triple quotes, """string with space""", and it should make the string passed to DMD include the string. Might be different for powershell.
You mean I could do -L/LIBPATH:"""path"""?
Yah you can try it with echo. echo "test with space" prints: test with space echo """test with space""" prints: "test with space"
Dec 30 2016
prev sibling parent Jerry <hurricane hereiam.com> writes:
On Friday, 30 December 2016 at 05:24:56 UTC, Jeremy DeHaan wrote:
 On Friday, 30 December 2016 at 04:56:59 UTC, Jerry wrote:
 On Friday, 30 December 2016 at 03:51:13 UTC, Jeremy DeHaan 
 wrote:
 How does one correctly add a linker path that has spaces?
The quotes get consumed by the command line. The way DMD spawns the linker by creating a new string with all the flags. So it smashes everything into a new string, ignoring how the string was passed into DMD. I think you can use triple quotes, """string with space""", and it should make the string passed to DMD include the string. Might be different for powershell.
You mean I could do -L/LIBPATH:"""path"""?
My mistake that's for powershell, I'm not sure what the cmd.exe way is.
Dec 30 2016
prev sibling parent reply Jeremy DeHaan <dehaan.jeremiah gmail.com> writes:
On Friday, 30 December 2016 at 04:56:59 UTC, Jerry wrote:
 On Friday, 30 December 2016 at 03:51:13 UTC, Jeremy DeHaan 
 wrote:
 How does one correctly add a linker path that has spaces?
The quotes get consumed by the command line. The way DMD spawns the linker by creating a new string with all the flags.
Does this happen on other platforms too? There has to be a GOOD way to pass a linker path that has spaces. Should this be considered as a bug?
Dec 30 2016
parent reply Rainer Schuetze <r.sagitario gmx.de> writes:
On 30.12.2016 19:24, Jeremy DeHaan wrote:
 On Friday, 30 December 2016 at 04:56:59 UTC, Jerry wrote:
 On Friday, 30 December 2016 at 03:51:13 UTC, Jeremy DeHaan wrote:
 How does one correctly add a linker path that has spaces?
The quotes get consumed by the command line. The way DMD spawns the linker by creating a new string with all the flags.
Does this happen on other platforms too? There has to be a GOOD way to pass a linker path that has spaces. Should this be considered as a bug?
Not sure if it qualifies as "GOOD", but this works: dmd -m64 "-L/LIBPATH:\"path with spaces\"" main.d
Dec 30 2016
parent Jeremy DeHaan <dehaan.jeremiah gmail.com> writes:
On Friday, 30 December 2016 at 21:51:32 UTC, Rainer Schuetze 
wrote:
 On 30.12.2016 19:24, Jeremy DeHaan wrote:
 On Friday, 30 December 2016 at 04:56:59 UTC, Jerry wrote:
 On Friday, 30 December 2016 at 03:51:13 UTC, Jeremy DeHaan 
 wrote:
 How does one correctly add a linker path that has spaces?
The quotes get consumed by the command line. The way DMD spawns the linker by creating a new string with all the flags.
Does this happen on other platforms too? There has to be a GOOD way to pass a linker path that has spaces. Should this be considered as a bug?
Not sure if it qualifies as "GOOD", but this works: dmd -m64 "-L/LIBPATH:\"path with spaces\"" main.d
Well, it's probably as good as it's going to get without dmd looking for this specifically or having something added. Thanks.
Dec 31 2016