c语言——gcc,make,vim

在linux环境下进行c语言编程,基础的工具就是gcc和make。关于这2个工具的内容有很多,现在要做的仅仅是起步。

gcc的用法:

-S Compile only; do not assemble or link
-c Compile and assemble, but do not link
-o<file> Place the output into <file>
-shared Create a shared library

make的用法:

建立makefile,makefile的语法如下:
target:prereq1 prereq2
commands

实例:

环境:

Ubuntu 13.04 (GNU/Linux 3.8.0-26-generic i686)

gcc version 4.7.3

mkdir src   #建立目录
#建立c源文件,写入如下内容:
vi hello.c    
#include<stdio.h>
int main()
{
        printf("%s
","Nice day.");
        return 0;
}
#建立makefile文件,写入如下内容
vi makefile run.out:hello.c gcc hello.c -o run.out #运行make命令,会自动执行makefile文件,将会生产run.out文件 make
#执行编译后的文件,会在终端显示Nice day. .
/run.out

 vim

对vim进行一些基础设置

#建立文件
vi ~/.vimrc
#写入如下内容,写的时候需要去掉注释
set nu   #显示行号
set autoindent            #自动缩进
set expandtab            #使用空格代替tab键
set softtabstop=4       #每个tab键等于4个空格
set encoding=utf-8     #文件的编码格式为utf-8
原文地址:https://www.cnblogs.com/zhizhou/p/3221542.html