安装编译器
sudo apt install -y build-essential
20.04版本下
sudo apt install openjdk-11-jdk # -y表示不询问直接安装
1.vim 编辑 hello.c
编辑hello.c
vim hello.c
2.编译指令
gcc -E hello.c -lm -o hello.i //仅预处理
gcc -S hello.i -lm -o hello.s //仅编译
gcc -c hello.s -lm -o hello.o //仅编译、汇编、不连接
gcc hello.o -lm -o hello //确定输出文件名
3.查看运行结果
./hello
4.使用gbd调试函数调用
4.1编写一个含有函数调用的test.c
4.2编译生成可执行文件
gcc -g tst.c -o tst
4.3启动GDB
gdb tst
4.4在main函数设置断点
run 或:run arg 1 arg 2
- gcc过程改为 makefile 管理
sudo makefile ysz
6.使用tftp远程调试
将hello.c和makefile复制到tftp文件下
sudo cp hello.c /tftp
sudo cp makefile /tftp