Linux与C语言交互
文章目录
环境:VMware Workstation
1. 编写Makefile
linux@ubuntu:~/test/exp3$ vi Makefile
Makefile
1 hello:hello.c
2 gcc -o hello hello.c
3 clean:
4 rm -f *.o
2. 编写hello.c
linux@ubuntu:~/test/exp3$ vi hello.c
hello.c
1 #include<stdio.h>
2 int main(){
3 printf("hello world!");
4 return 0;
5 }
~
3. 运行Makefile文件
linux@ubuntu:~/test/exp3$ make
gcc -o hello hello.c
- ls查看文件,文件中多了hello,说明Makefile运行成功
linux@ubuntu:~/test/exp3$ ls
4. 运行hello.c
linux@ubuntu:~/test/exp3$ ./hello