# introduction for rules # $@ 表示目标文件 # $^ 表示所有的依赖文件 # $< 表示第一个依赖文件 # $? 表示比目标还新的依赖文件列表 # example # main: main.o hello.o hi.o # gcc -o main main.o hello.o hi.o # 其中,main就是目标文件,所有的依赖文件为 main.o hello.o hi.o # 此时,...
拿C语言来说,编译的时候 gcc 只会默认链接一些基本的C语言标准库,很多源文件依赖的标准库都需要我们手动链接。 下面列举了一些需要我们手动链接的标准库: name1.c 用到了数学计算库 math 中的函数,我们得手动添加参数 -Im; name4.c 用到了小型数据库 SQLite 中的函数,我们得手动添加参数 -lsqlite3; name5....
#*tousenon-standardC/C++libraries,setpre-processororcompiler #optionstoandlinkeronesto #(SeeMakefile.gtk+-2.0foranexample)#*tosearchsourcesinmoredirectories,setto<SRC_DIRS> #*tospecifyyourfavoriteprogramname,setto<APP> #3.Typemaketostartbuildingyourprogram.# #MakeTarget:#--- #TheMakefileprovides...
下面列举了一些需要我们手动链接的标准库: name1.c 用到了数学计算库 math 中的函数,我们得手动添加参数 -Im; name4.c 用到了小型数据库 SQLite 中的函数,我们得手动添加参数 -lsqlite3; name5.c 使用到了线程,我们需要去手动添加参数 -lpthread。 因为有很多的文件,还要去链接很多的第三方库。所以在编译的...
# Generic Makefile for C/C++ Program # # License: GPL (General Public License) # Author: whyglinux <whyglinux AT gmail DOT com> # Date: 2006/03/04 (version 0.1) # 2007/03/24 (version 0.2) # 2007/04/09 (version 0.3) # 2007/06/26 (version 0.4) ...
目标“.o” 文件存在,目标 “.o” 文件所依赖的 “.c” 源文件 “.h” 文件中的任何一个比目标 “.o” 文件“更新”(在上一次 make 之后被修改)。则根据规则重新编译生成它; 目标“.o” 文件存在,目标 “.o” 文件比它的任何一个依赖文件(“.c” 源文件、“.h” 文件)“更新”(它的依赖文件在...
# * to use non-standard C/C++ libraries, set pre-processor or compiler # options to and linker ones to # (See Makefile.gtk+-2.0 for an example) # * to search sources in more directories, set to <SRC_DIRS> # * to specify your favorite program name, set to <APP> ...
foo=one two threeall:foriin$(foo);do\ echo $$i;\ end 就可以正常打印:one two three。 这是因为$i命令被make翻译成了shell中的i,而此时shell中的i的值就是one two three. 通配符 在Makefile中,*和%是都属于通配符。下面来看下他们的用法。
让我们创建一个更典型的 Makefile - 一个编译单个 C 文件的文件。但在我们这样做之前,请创建一个名为的文件,该文件blah.c具有以下内容: // blah.c int main() { return 0; } 然后创建 Makefile(Makefile一如既往地称为): blah: cc blah.c -o blah ...
# Generic Makefile for C/C++ Program # # License: GPL (General Public License) # Author: whyglinux <whyglinux AT gmail DOT com> # Date: 2006/03/04 (version 0.1) # 2007/03/24 (version 0.2) # 2007/04/09 (version 0.3) # 2007/06/26 (version 0.4) ...