I have a makefile that has C INCLUDES with spaces in them. There is no way for me to get around having to have the spaces in the file names. Is there any way to have spaces in file names with gnu make?
Asked
Active
Viewed 262 times
-1
-
If you can't explain why you can't get around the spaces, there won't be much help I'm afraid. Maybe post the MAKEFILE? – Matt Runion Feb 01 '13 at 04:49
-
if it can be gotten around at all it would be with a "\" in front of the space to escape it, but I'm not sure that will work in a makefile – djjolicoeur Feb 01 '13 at 04:50
-
i cant get around the spaces becos the makefile is this: LOCAL_C_INCLUDES:=C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\ and i need to include the libraries in there :S – ChrisC Feb 01 '13 at 16:46
-
Duplicate: https://stackoverflow.com/q/9838384/ – Alexey Feb 14 '18 at 22:31
1 Answers
0
Make has some basic support for this by escaping spaces in filenames, in that the following Makefile will correctly compile and recompile the C file foo bar.c
:
foo\ bar: foo\ bar.c
gcc -o "${@}" "${<}"
However, you have to be super-careful in quoting every command you run, and variables that are space-separated lists of files—e.g., SRCS
, LIBS
—won’t work, although it’ß possible that with enough hacking using Make text functions you can parse out the quotes and get everything working…
So while there is rudimentary support for spaces in filenames in rules and patterns, anything complicated is going to be an awful lot of very hard and frustrating work.

andrewdotn
- 32,721
- 10
- 101
- 130
-
sry , i dont get this example. i am stating LOCAL_C_INCLUDES := C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\ – ChrisC Feb 01 '13 at 16:51