linux下编译运行的第一个C
2011-09-02 11:11
316 查看
linux下运行的第一个C程序
root@localhost root]# vi hello.c
进入vim的命令模式,按下键盘的i切换到插入模式,输入如下代码:
#include <stdio.h>
int main()
{
printf("Hello! This is our embeded world!/n");
return 0;
}
按下Esc进入命令模式,输入:wq,自然会保存文件会退回到终端
接下来就是预处理、链接、编译、运行拉
[root@localhost root]# gcc -E hello.c -o hello.i //预处理
[root@localhost root]# gcc -S hello.i -o hello.s //编译不汇编,生成汇编文件
[root@localhost root]# gcc -c hello.s -o hello.o //编译不链接。生成目标文件
[root@localhost root]# gcc hello.o -o hello //生成执行文件
[root@localhost root]# ./hello //运行执行文件
Hello! This is our embeded world! //这就是输出的结果
root@localhost root]# vi hello.c
进入vim的命令模式,按下键盘的i切换到插入模式,输入如下代码:
#include <stdio.h>
int main()
{
printf("Hello! This is our embeded world!/n");
return 0;
}
按下Esc进入命令模式,输入:wq,自然会保存文件会退回到终端
接下来就是预处理、链接、编译、运行拉
[root@localhost root]# gcc -E hello.c -o hello.i //预处理
[root@localhost root]# gcc -S hello.i -o hello.s //编译不汇编,生成汇编文件
[root@localhost root]# gcc -c hello.s -o hello.o //编译不链接。生成目标文件
[root@localhost root]# gcc hello.o -o hello //生成执行文件
[root@localhost root]# ./hello //运行执行文件
Hello! This is our embeded world! //这就是输出的结果
相关文章推荐
- Opencv学习1: 在Linux下编译运行第一个opencv程序
- 第一个java程序的编译和运行(linux下安装JDK)------一次编译,到处运行
- 记录一下Linux下安装Qt5.6到命令行编译方式顺利运行第一个helloworld全过程
- 在Linux最小系统上编译运行第一个helloworld程序
- linux下编译运行的第一个C
- Linux下编译并运行的第一个程序
- 编译运行第一个linux c++程序
- 如何在虚拟机中linux系统用gcc编译并运行第一个C++程序
- linux下运行《UNIX环境高级编程》的第一个程序时源码编译出错的处理方法
- Linux下使用GCC编译并运行第一个helloworldC++程序
- android手机编译可运行的linux程序
- 学习DirectFB之:编译运行第一个DirectFB程序
- VirtualBox运行自已编译的Linux
- Linux下C程序的编辑,编译和运行以及调试
- 让C/C++程序一次编译,到处运行 (仅限Linux)
- 在linux 上编译生成windows上运行的exe程序,交叉编译环境的配置( 平台:gentoo linux)
- 在linux上,用scalac编译在Spark平台上运行的scala程序
- mxnet 编译后运行的第一个demo train_mnist.py时的错误
- 一个最简单的linux驱动程序的编译运行
- Android 运行 C/C++程序 (使用 arm-linux-gcc 交叉编译环境)