gcc、g++和gdb的使用
2012-10-09 13:48
197 查看
gcc编译运行C程序
#include <stdio.h>
int main(void)
{
printf ("Hello world, Linux programming!\n");
return 0;
}
1、编写程序vim hello.c保存后退出
2、编译代码gcc hello.c
3、添加可执行权限chmod +x a.out
4、运行程序./a.out
5、运行结果
Hello world, Linux programming!
1、编写程序vim hello.c保存后退出
2、编译代码gcc hello.c -o hello.out
3、添加可执行权限chmod +x hello.out
4、运行程序./hello.out
5、运行结果
Hello world, Linux programming!
gdb的使用
1、在编译程序时加入调试信息
gcc -g -o hello.debug hello.c
2、启动gdb
gdb
3、在gdb中加载需要调试的程序
file hello.debug
4、在gdb中查看代码
list 1
5、在程序中加入断点
break 5
6、运行程序
run
在断点处停下输入next或者step继续
7、变量的查看
print i
g++编译运行c++程序
#include <iostream>
using namespace std;
int main()
{
cout<<"Hello!\n";
return 0;
}
1、编写程序vim hello.cpp保存后退出
2、编译代码g++ hello.pp
3、添加可执行权限chmod +x a.out
4、运行程序./a.out
5、运行结果
Hello!
1、编写程序vim hello.cpp保存后退出
2、编译代码gcc hello.cpp -o hello.out
3、添加可执行权限chmod +x hello.out
4、运行程序./hello.out
5、运行结果
Hello!
#include <stdio.h>
int main(void)
{
printf ("Hello world, Linux programming!\n");
return 0;
}
1、编写程序vim hello.c保存后退出
2、编译代码gcc hello.c
3、添加可执行权限chmod +x a.out
4、运行程序./a.out
5、运行结果
Hello world, Linux programming!
1、编写程序vim hello.c保存后退出
2、编译代码gcc hello.c -o hello.out
3、添加可执行权限chmod +x hello.out
4、运行程序./hello.out
5、运行结果
Hello world, Linux programming!
gdb的使用
1、在编译程序时加入调试信息
gcc -g -o hello.debug hello.c
2、启动gdb
gdb
3、在gdb中加载需要调试的程序
file hello.debug
4、在gdb中查看代码
list 1
5、在程序中加入断点
break 5
6、运行程序
run
在断点处停下输入next或者step继续
7、变量的查看
print i
g++编译运行c++程序
#include <iostream>
using namespace std;
int main()
{
cout<<"Hello!\n";
return 0;
}
1、编写程序vim hello.cpp保存后退出
2、编译代码g++ hello.pp
3、添加可执行权限chmod +x a.out
4、运行程序./a.out
5、运行结果
Hello!
1、编写程序vim hello.cpp保存后退出
2、编译代码gcc hello.cpp -o hello.out
3、添加可执行权限chmod +x hello.out
4、运行程序./hello.out
5、运行结果
Hello!
相关文章推荐
- Linux gcc/g++下GDB调试及其调试脚本的使用
- Linux-CentOS环境下使用yum命令安装gcc/g++/gdb
- windows 平台g++、gcc、gdb编译环境搭建及使用示范【详细步骤】
- 【Linux】gcc/g++、gdb、vim的安装及使用
- gcc/g++使用第三方库时添加头文件路径和库文件路径的方法
- matlab r2015b修改mex使用的gcc g++版本
- 在Linux中使用VS Code编译调试C++项目(gcc/g++、Makefile入门、vs code)
- gdb和g++的简单使用
- gdb和g++的简单使用
- cygwin的安装,vi的使用,gcc,g++的使用
- 在Linux下如何使用命令安装gcc/g++, gdb, vim
- Linux下C/C++编译器GCC/G++使用简介
- gcc和gdb简单使用
- 使用gcc -g编译,gdb调试时仍然存在“no debug symbols found”的错误
- 如何使用命令安装gcc/g++, gdb, vim
- 如何在Ubuntu 12.04 LTS中使用低版本gcc/g++
- 使用gdb调试程序详解和GCC参数详解
- 使用gcc/g++学习编译流程
- 使用gcc和 gdb,调试程序
- gcc/g++ 编译器使用简介