- 论坛徽章:
- 0
|
有下面几个程序:
//fun.h
#ifndef FUN_H
#define FUN_H
double fun(double);
#endif
//fun.cpp
#include "fun.h"
#include <math.h>
double fun(double x){
return sin(x);
}
//foo.h
#ifndef FOO_H
#define FOO_H
double foo(double,double);
#endif
//foo.cpp
#include "foo.h"
#include "fun.h"
double foo(double x,double h){
...
return fun(x+h);
...
}
//main.cpp
#include <iostream>
#include "foo.h"
#include "fun.h"
using namespace std;
int main(int argc,char*argv[]){
cout<<foo(3,5);
return 0;
}
//makefile
main:main.o foo.o fun.o
g++ -o main main.o foo.o fun.o
main.o:main.cpp foo.h fun.h
g++ -c main.cpp
foo.o:foo.cpp foo.h fun.h
g++ -c foo.cpp
fun.o:fun.cpp fun.h
g++ -c fun.cpp
clean:
rm *.o
请大虾指点我的makefile怎么老是说没有定义fun?谢谢! |
|