文章目录
基于Linux系统搭建c开发环境
1.安装VmWare
比较详细
https://blog.csdn.net/SoulNone/article/details/126681722
配置网络适配器和cd驱动
尽量使用桥接模式
2.安装Ubuntu
百度
Ubnutu常用命令:https://blog.csdn.net/wqda125/article/details/127865494
3.搭建samba服务器
3.1apt-get在线包安装
3.1.1.安装samba软件
sudo apt-get install samba 以管理员权限安装samba
sudo apt-get remove samba 以管理员权限卸载samba
3.1.2.添加共享用户信息
smbpasswd -a 用户名
3.1.3.配置文件信息
sudo gedit /etc/samba/smb.conf
[share] 路径:path=/home/用户名/share 权限:writable=yes 共享用户名:valid user=用户名
3.1.4启动samba服务器
sudo /etc/init.d/samba restart
4.安装Vim编辑器
4.1安装vim编辑器
sudo apt-get install vim
4.2配置vim编辑器
/etc/vim/vimrc
在文件末尾设置行号
set number
4.3启动vim编辑器
vi hello.c
打开 hello.c文件
vim hell.c
如果文件名省略,内容直接存储在vim编辑器的缓冲区中,不存储在磁盘。
如果文件名省略,在启动vim编辑器时将文件的数据读取到缓存区中,在保存时候把数据写从缓存区写入到文件中
4.4插入模式进入编辑
i/I/a/A/s/S
#include <studo.h>
int main(){
printf ("hello c"\n);
return 0;
}
退出
esc
:wq 保存并退出
5.程序编译流程
下载 gcc : sudo apt-get install gcc
5.1预处理
实现对头文件展开,宏定义替换
对hello.c文件预处理到 hello.i文件
-E :预处理选项 -0 指定输出
gcc -E hello.c -o hello.i
5.2编译
实现程序语法检测和汇编处理,最后生成汇编代码
对预处理的hello.i文件 编译到 hello.s文件
-S 编译选项
gcc -S hello.i -o hello.s
5.3汇编
实现汇编代码翻译成机器指令代码
-C 汇编指令
gcc -C hello.s -o hello.o
5.4链接
实现整个程序的多个.o文件的链接,程序来链接需要的依赖库,和API接口,链接启动程序
gcc hello.o -o hello
5.5直接编译
gcc hello.c
./a.out
可以直接创建 vi hello.c
创建完直接打开编辑器
加入头文件
#include<studo.h>
int main(){
printf("hello c \n");
return 0;
}
//退出编辑器 ESC
输入 :
//保存并退出
wq