上机20 gcc makefile gdb ide eclipse

安装编译器

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

在这里插入图片描述

  1. gcc过程改为 makefile 管理

sudo makefile ysz

在这里插入图片描述

6.使用tftp远程调试

将hello.c和makefile复制到tftp文件下

sudo cp hello.c /tftp

sudo cp makefile /tftp

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值