zoukankan      html  css  js  c++  java
  • linux mint gcc 编译第一个c程序

        GCC是Linux操作系统下一个非常重要的源代码编译工具,有着许多重要的选项,支持许多不同语言的编译,如C、C++、Ada、 Fortran、Objective、Perl、Python、Ruby以及Java等,甚至Linux的许多内核和许多其他自由软件以及开放源码应用程 序都是用C语言编写并经gcc编译而成的.

        1.编译单个源文件

        [例如]在屏幕上打印"Hello,Linux."

        [源代码]

        #include<stdio.h>

        #include<stdlib.h>

        int main(int argc,char **argv)

        {

            printf("Hello,Linux. ");

            exit(0);

        }

        将源文件保存为hello.c,开始进行编译

        $gcc -o hello hello.c

        编译成功完成后,在当前路径下,生成一个名为hello的文件,然后执行

        $./hello

        在屏幕上,你将会看到打印结果:Hello,Linux.

    重要:若提示找不到include 的文件错误

    则:$ sudo apt-get install build-essential                    ($不要复制)

    重新编译就可以了

  • 相关阅读:
    (一)Sturts2概述
    day18,常用的模块,os,sys...等
    day17,模块的导入
    day16
    day15
    day14
    day13
    day12
    day11
    day10
  • 原文地址:https://www.cnblogs.com/liunnis/p/4680076.html
Copyright © 2011-2022 走看看