Skip to content

Linux基础与应用开发 ​

飞书原文

交叉编译 ​

交叉编译:在x86主机上编译生成ARM目标平台可执行程序的过程。

Shell常用命令 ​

命令作用
ls / cd / pwd目录操作
cp / mv / rm文件操作
cat / grep文本查看与搜索
ps / top进程查看

GCC编译 ​

bash
gcc -c main.c -o main.o
gcc main.o utils.o -o app
选项作用
-o指定输出文件名
-c只编译不链接
-I指定头文件路径
-g生成调试信息

Makefile ​

makefile
app: main.o utils.o
	gcc main.o utils.o -o app

main.o: main.c
	gcc -c main.c

clean:
	rm *.o app

文件IO编程 ​

c
int fd = open("test.txt", O_RDWR | O_CREAT, 0644);
write(fd, "hello", 5);
read(fd, buf, 5);
close(fd);

进程与线程 ​

进程线程
内存独立地址空间共享地址空间
开销大小
通信需IPC机制直接共享变量

网络编程 ​

c
int sockfd = socket(AF_INET, SOCK_STREAM, 0);
bind(sockfd, ...);
listen(sockfd, 10);
int clientfd = accept(sockfd, ...);
read(clientfd, buf, 1024);

SQLite ​

SQLite:嵌入式轻量级关系型数据库,无需独立服务器进程,读写单个文件。


Linux应用开发核心:Shell命令+GCC编译+文件IO+进程线程+网络编程+数据库。