谢谢 https://blog.youkuaiyun.com/nicholas_liu2017/article/details/78323391
MinGW下载网页:http://sourceforge.net/projects/mingw/files/latest/download?source=files
D:\Program Files\MinGW\bin 中, 将mingw32-make.exe重命名为make.exe。
测试: main.cpp
:
#include<stdio.h>
#include<stdlib.h>
int main(void){
printf("Hello, world!\n");
getchar();
system("pause");
return 0;
}
int max(int a, int b);
下面介绍处理多个文件,如图所示:
max_num.c:
#include <stdio.h>
#include <stdlib.h>
#include "max.h"
int main(void)
{
int maxRes=max(3, 5);
printf("The bigger one of 3 and 5 is %d\n", maxRes);
getchar();
system("pause");
return 0;
}
max.h:
int max(int a, int b);
max.c:
#include "max.h"
int max(int a, int b)
{
return a > b ? a : b;
}
makefile:
max_num.exe: max_num.o max.o
gcc -o max_num.exe max_num.o max.o
max_num.o: max_num.c max.h
gcc -c max_num.c
max.o: max.c max.h
gcc -c max.c
注意所有含有gcc的行前面是一个制表符,而非若干空格。否则可能会保存,无法编译。
OK,完成。