In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-27 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/03 Report--
Do we have all the source files and header files in the same folder in the actual project? If it is a relatively small project, of course it is possible. But if there are thousands of source files, of course you have to store them separately. The commonly used source code management methods are as follows
So can the following makefile be compiled successfully?
Let's give it a try. The compilation results are as follows
Then the result must be like this, because we did not specify a path in makefile, it did not find the source file in the current directory. Next we have to introduce a special predefined variable VPATH (all uppercase). The value of the VAPTH variable is used to tell make how to find files, different folders can appear at the same time as the value of VPATH, and the names of folders need to be distinguished by delimiters. The format is as follows
Make for the VAPTH value of the way: 1, the current folder can not find the required files, VAPTH will be used; 2, make will be specified in the VAPTH folder to search for files; 3, when multiple folders have files of the same name, select the first search for the file. Note: 1, VAPTH can only determine the search path of make, but not the search path of the command; 2, for specific compilation commands (gcc), you need to specify the compilation search path independently. As follows
Let's take the code as an example and rewrite it on the basis of the makefile above.
OBJS: = func.o main.oINC: = incSRC: = srcVPATH: = $(INC) $(SRC) hello.out: $(OBJS) @ gcc-o $@ $^ @ echo "Target File = > $@" $(OBJS):% .o:% .c func.h @ gcc-o $@-c $^
Let's compile and try.
Do you see the compilation or the error? the reason is that when we gcc, the dependent file also contains func.h. Let's change the $^ of the last line to $.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.