哎呀,刚接触makefile 和 linux 不久,搞得很多C++的东西都抛诸脑后了,真的惭愧哟。
这是我的文件目录(实际开发最好不要这样命名文件,否则到之后自己都不知道这些文件都是干嘛的)
一开始的源代码:
.1 头文件
#include <iostream>
using std::cout;
using std::endl;
extern int value;
void setValue(int tmp);
.1 源文件
#include "1.h"
void setValue(int tmp)
{
value = tmp;
}
.2 头文件
#include <iostream>
using std::cout;
using std::endl;
extern int value;
void getValue();
.2 源文件
#include "2.h"
void getValue()
{
cout << "value:" << value << endl;
}
.main 文件
#include <iostream>
#include "1.h"
#include "2.h"
int value;
int main(int argc, char** argv)
{
setValue(100);
getValue();
}
Makefile 文件
SRC = $