.cpp在src目录下;
.o 在build目录下;
.h在include目录下;
makefile在mak目录下。。。
1.src下的.cpp文件
#include "../include/all.h"
int addb(int x,int y)
{
return(x+y);
}
#include "../include/all.h"
int sub(int x,int y)
{
return(x-y);
}
#include "../include/all.h"
int mul(int x,int y)
{
return(x*y);
}
#include "../include/all.h"
int div(int x,int y)
{
return(x/y);
}
2.include下的.h文件
#ifndef MAIN_H_
#define MAIN_H_
int addb(int x,int y);
int sub(int x,int y);
int mul(int x,int y);
int div(int x,int y);
#endif
3.mak下Makefile
CC=g++
OBJ=test
SRCS=../build/add.o ../build/sub.o ../build/mul.o ../build/div.o ../build/main.o
path=-I ../include
$(OBJ):$(SRCS)
$(CC) $(SRCS) -o $@
../build%.o:../src%.cpp
$(CC) $(path) -c $< -o $@
clean:
rm -f ../build/*.o