博客
关于我
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/

你可能感兴趣的文章
npm install 报错 EEXIST File exists 的解决方法
查看>>
npm install 报错 ERR_SOCKET_TIMEOUT 的解决方法
查看>>
npm install 报错 Failed to connect to github.com port 443 的解决方法
查看>>
npm install 报错 fatal: unable to connect to github.com 的解决方法
查看>>
npm install 报错 no such file or directory 的解决方法
查看>>
npm install 权限问题
查看>>
npm install报错,证书验证失败unable to get local issuer certificate
查看>>
npm install无法生成node_modules的解决方法
查看>>
npm install的--save和--save-dev使用说明
查看>>
npm node pm2相关问题
查看>>
npm run build 失败Compiler server unexpectedly exited with code: null and signal: SIGBUS
查看>>
npm run build报Cannot find module错误的解决方法
查看>>
npm run build部署到云服务器中的Nginx(图文配置)
查看>>
npm run dev 和npm dev、npm run start和npm start、npm run serve和npm serve等的区别
查看>>
npm run dev 报错PS ‘vite‘ 不是内部或外部命令,也不是可运行的程序或批处理文件。
查看>>
npm scripts 使用指南
查看>>
npm should be run outside of the node repl, in your normal shell
查看>>
npm start运行了什么
查看>>
npm WARN deprecated core-js@2.6.12 core-js@<3.3 is no longer maintained and not recommended for usa
查看>>
npm 下载依赖慢的解决方案(亲测有效)
查看>>