makefile 本质上是定义可一套规则,对工程源进行编译 程序链接,先举一个小例子以展开makefile的讲解,其他makefile 具体含义和好处 不详谈;
首先建立一个test文件,然后建立三个文件百度分享 (http://pan.baidu.com/s/1miRnbtu)
mkdir test
cd test
touch hello.cpp
vi hello.cpp然后输入代码
touch test.h
vi test.h 然后输入代码
touch makefile
vi makefile 然后输入规则
#include<iostream>
using namespace std;
void print()
{cout<<"i am a student"<<endl;}
test.h源文件
#include"test.h"
#include<iostream>
using namespace std;
int main(int argc,char* argv[])
{cout<<"hello world"<<endl;
print();
return 0;
}
hello.cpp源文件
object=hello.o
hello:$(object)
g++ -o hello -g $(object)
$(object):hello.cpp test.h
g++ -o $(object) -c hello.cpp
clean:
rm hello $(object)
makefile 文件
简要说一下源文件 只是一个普通的"hello world" 程序,在ubun