GCC编译C/C++/汇编代码

来源:互联网 发布:windows xp sp3 msdn 编辑:程序博客网 时间:2024/04/29 18:33

环境是ubuntu10.04

编译器是GCC

 

一、安装GCC

   【Applications】-->【Terminal】,命令输入:

    sudo apt-get install build-essential

 

二、C语言打印hello world!

文件:test.c

 

编译:            gcc -o test test.c

运行:            ./test

 

三、C++语言打印hello world!

文件:test.cpp

 

 

编译:            g++ -o test test.cpp

运行:            ./test

四、汇编语言打印hello world!
文件:test.s
 
汇编:          as test.s -o test.o
链接:          ld test.o -o test
运行:          ./test
注:编译程序时,需先进入源文件(代码)目录,如:cd src

 

 

原创粉丝点击