g++ makefile


文件清单

 

$ ls
daemon.cc  daemon.h  makefile  say.cc  show.cc

$ cat daemon.h 
#ifndef _DAEMON_H_
#define _DAEMON_H_
void show();
void say();

#endif


$ cat daemon.cc 
#include "daemon.h"

int main(){
	show();
}

$ cat say.cc 
#include <iostream> 
using namespace std ;
#include <sys/types.h>
#include <unistd.h>
void say(){
	cout << "this is from say() \n" << endl;
	cout << "this pid = " << getpid() << endl ;
}

$ cat show.cc 
#include "daemon.h"
using namespace std ;
#include <iostream> 

void show(){
	cout << "hello this is from show()" << endl;
	say();
}

$ cat makefile 
aa: daemon.o show.o say.o
	g++ daemon.o show.o say.o -o aa
daemon.o: daemon.cc daemon.h
	g++ -c daemon.cc daemon.h
show.o: show.cc daemon.h
	g++ -c show.cc daemon.h
say.o: say.cc
	g++ -c say.cc

clean: 
	rm -rf *.o *.gch

$ make
g++ -c daemon.cc daemon.h
g++ -c show.cc daemon.h
g++ -c say.cc
g++ daemon.o show.o say.o -o aa

$ ./aa 
hello this is from show()
this is from say() 

this pid = 7549

$ make clean 
rm -rf *.o *.gch 

https://gcc.gnu.org/onlinedocs/gcc/Precompiled-Headers.html


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值