博客
关于我
linux下编译C语言常用命令(未完待续)
阅读量:591 次
发布时间:2019-03-09

本文共 1154 字,大约阅读时间需要 3 分钟。

Linux下编译C语言常用命令

1. 文件管理命令

Linux系统的文件管理命令是日常开发中的核心工具。以下是一些常用的文件管理命令:

命令名称 功能描述 示例
mkdir 创建新文件夹 mkdir testmkdir -p /test/test1
cd 切换工作目录 cd test
ls 列出当前目录的文件和目录 lsls -R 列出所有子目录,ls -a 显示隐藏文件
pwd 显示当前工作目录 pwd
cp 复制文件或目录 cp 文件名 目标路径cp -r 文件夹 目标路径
rm 删除文件或文件夹 rm 文件名rm -r 文件夹
mv 移动文件或文件夹 mv 输出文件 输入文件
cat 查看文件内容 cat 文件名cat -n 文件名(显示Numerical编号)
touch 创建文件或更新文件时间戳 touch 文件名touch -n 文件名

2. Vim编辑器

Vim 是 Linux 增强版文本编辑器,功能强大且灵活。以下是 Vim 的基本使用技巧:

  • 编辑模式

    模式名称 描述
    可视模式 (Visual Mode) 按下 i 进入插入模式,按下 Esc 退出
    编辑模式 (Insert Mode) 在可视模式下输入内容,按 Esc 退出
    末行模式 (Command Line Mode) 进入末行模式后,可以使用 Vim 的命令
  • 末行模式命令

    命令 描述
    :w (>write) 保存当前文件
    :q (!) 强制退出编辑器
    :q 退出编辑器(若未修改文件则需用户确认)
    :x 保存并退出(等效于 :wq)
    :set nu 显示行号

3. GCC 编译 C 程序

GCC 是 Linux 上的标准 C 编译器,以下是编译 C 程序的基本命令和参数:

对于 C 或 C++ 文件,可以使用:

gcc [options] [file1] [file2] ... [-o 输出文件]

参数选项 功能描述
-o 指定输出文件的名称
-c 仅编译源文件,生成可执行文件(不适用于 C++),用于静态链接
-Wall 开启所有警告选项,帮您优化代码
-lm 链接到数学库(libm)
编译指令示例 描述
gcc test.c -o test 编译单个源文件 test.c,并将其输出为可执行文件 test
gcc test1.c test2.c -o output 同时编译多个源文件 test1.c 和 test2.c,输出为可执行文件 output
gcc test.c -c -o test.o 仅编译源文件 test.c,输出为目标文件 test.o
gcc test.o test1.o -o output 将多个目标文件编译为一个可执行文件 output

转载地址:http://xhppz.baihongyu.com/

你可能感兴趣的文章
NMF(非负矩阵分解)
查看>>
nmon_x86_64_centos7工具如何使用
查看>>
NN&DL4.1 Deep L-layer neural network简介
查看>>
NN&DL4.3 Getting your matrix dimensions right
查看>>
NN&DL4.7 Parameters vs Hyperparameters
查看>>
NN&DL4.8 What does this have to do with the brain?
查看>>
nnU-Net 终极指南
查看>>
No 'Access-Control-Allow-Origin' header is present on the requested resource.
查看>>
NO 157 去掉禅道访问地址中的zentao
查看>>
no available service ‘default‘ found, please make sure registry config corre seata
查看>>
No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?
查看>>
no connection could be made because the target machine actively refused it.问题解决
查看>>
No Datastore Session bound to thread, and configuration does not allow creation of non-transactional
查看>>
No fallbackFactory instance of type class com.ruoyi---SpringCloud Alibaba_若依微服务框架改造---工作笔记005
查看>>
No Feign Client for loadBalancing defined. Did you forget to include spring-cloud-starter-loadbalanc
查看>>
No mapping found for HTTP request with URI [/...] in DispatcherServlet with name ...的解决方法
查看>>
No mapping found for HTTP request with URI [/logout.do] in DispatcherServlet with name 'springmvc'
查看>>
No module named 'crispy_forms'等使用pycharm开发
查看>>
No module named cv2
查看>>
No module named tensorboard.main在安装tensorboardX的时候遇到的问题
查看>>