Space and makefile

I am trying to compile a project with a space in the path directories. here you have a Makefile:

NAME = ./Release/Online_pricer SRCS = ./Online_pricer/main.cpp \ ./Online_pricer/Currency.cpp \ ./Online_pricer/Curve.cpp \ ./Online_pricer/Environment.cpp \ ./Online_pricer/My_convert.cpp \ ./Online_pricer/My_exception.cpp \ ./Online_pricer/ParserTab.cpp \ ./Online_pricer/Spot.cpp \ ./Online_pricer/Volatility.cpp \ ./Online_pricer/VolatilityCapFloor.cpp \ ./Online_pricer/VolatilitySwaption.cpp \ ../Files\\ cpp/Functions.cpp \ ../Files\\ cpp/UtilitiesWeb.cpp ##################################################### OBJS = $(SRCS:.cpp=.o) CC = g++ RM = rm -f CFLAGS = -g -W -Wall -Werror INCL = ../Files\ .h/ ##################################################### $(NAME) : $(OBJS) @$(CC) $(OBJS) -I$(INCL) $(LIB) -o $(NAME) @printf "\n \033[33m[Message]\033[39m Compilation under Linux done\n" .cpp.o : @$(CC) -I$(INCL) $(CFLAGS) -c $< -o $@ @printf " \033[34m[Compilation]\033[39m %s\n" $< re : fclean all all : $(NAME) clean : @$(RM) *~ $(OBJS) @printf " \033[31m[Delete] \033[39m%s\n" $(OBJS) fclean : clean @$(RM) $(NAME) @printf "\n \033[31m[Delete] \033[39m%s\n" $(NAME) 

When I run "make re", I have this result:

 make: *** No rule to make target `../Files\', needed by `Release/Online_pricer'. Stop. 

I was unable to fix this problem in a directory with a space. Files cpp directory name.

Can anybody help me plz?

edit: I try with one \ and it does not work. I had this result:

 g++: error: ../Files: No such file or directory g++: error: cpp/Functions.cpp: No such file or directory g++: error: cpp/Functions.o: No such file or directory g++: fatal error: no input files compilation terminated. make: *** [../Files cpp/Functions.o] Error 4 
+4
source share
3 answers

As suggested by Tio Pepe, you should simply create a symbolic link to this directory ln -s Files\ cpp Files_cpp (and any other file with spaces) and use Files_cpp in your Makefile, and you will save countless hours trying to figure out how make handles spaces.

Yes, these double backward smoothings are true, but in the future, using $(SRCS:.cpp=.o) and $(OBJS) will only result in paths without any spaces. As this page indicates, you will have to decode and encode the paths - I tried to do this with a simple example, failing every time, so let me tell you - you are much better than not dealing with spaces on the roads. Rename the directory or use a symbolic link without spaces.

+7
source

Use the 8.3 filename instead. Use dir / x to find out what it is

0
source

I am very close to resolving the issue. I have all my OBJFILES, SRCFILES, etc., correctly formed in this way. "/ home / latency / projects / Function pointers / depend on" .depends "

When I move on to creating an assembly rule, I run into problems.

-switch $ (BINPATH) / $ (DEPSFILE)

 make: *** No rule to make target `\"/home/latency/projects/Function', needed by `/home/latency/projects/Function'. Stop. 

I'm not sure what to do at the moment. But I decided to set some build rules, and I got this thing to work everywhere with spaces in file names and dirs.

0
source

Source: https://habr.com/ru/post/1399157/


All Articles