![](https://img-blog.csdnimg.cn/20200502225752255.jpg?x-oss-process=image/resize,m_fixed,h_224,w_224)
Linux
各种Linux基础知识
Rice__
走走停停
展开
-
gdb及其core调试
gdb快速入门 (1) 编译时需加 -g参数,gdb + app进入调试 r或run运行,退出q (2) 启动, start停在main函数 (3) n或next下一条指令 (4) s或step下一条指令,可以进入函数内部(非库函数) (5) 运行前指定参数 set args 1 2(也可用于改变变量值) 或直接 run 1 2 (6) 断点b或break, c或continue下一个断点,d删除断点,条件断点+if (7) p或print打印变量值,ptype打印变量类型,list查看源码 (8) di.原创 2020-08-19 21:30:36 · 241 阅读 · 0 评论 -
静态与动态链接库
静态库(.a后缀) (1)生成.o文件(即二进制文件,gcc -c生成) (2)生成库: ar rcs libCalc.a *.o (3)查看: nm + 静态库文件.a (4)使用: gcc -main.c -o app -L lib/ -l Calc (-l指定库名,把lib与后缀去掉) 动态库(共享库) (1)与位置无关,即通过偏移量去查找 -fPIC 作用于编译阶段,告诉编译器产生与位置无关代码(Position-Independent Code),运行时加入内存 (2)生成二进制: g..原创 2020-08-19 21:23:46 · 114 阅读 · 0 评论 -
Linux的奇怪错误记录
error: ‘for’ loop initial declarations are only allowed in C99 mode for(int i = 0; i < 31; i++){ note提示里面已有解决方法 note: use option -std=c99 or -std=gnu99 to compile your code 所以gcc只需要添加参数: gcc -std=c99 target.c error: unknown type name ‘sigset_t.原创 2020-07-08 17:20:49 · 1618 阅读 · 0 评论 -
Linux--shell小总结
1.shell环境 Shell 脚本(shell script),是一种为 shell 编写的脚本程序。业界所说的 shell 通常都是指 shell 脚本,通常用的是 Bash,也就是 Bourne Again Shell,由于易用和免费,Bash 在日常工作中被广泛使用。同时,Bash 也是大多数Linux 系统默认的 Shell。 在一般情况下,人们并不区分 Bourne Shell 和 Bourne Again Shell,所以,像 #!/bi原创 2020-05-11 15:59:05 · 164 阅读 · 0 评论 -
Linux--gcc/gdb基础
(1)gcc编译器 后缀名解释 gcc通过后缀来区别输入文件的类别: .c 为后缀的文件:C语言源代码文件 .a 为后缀的文件:是由目标文件构成的库文件 .C,.cc或 .cxx为后缀的文件:是C++源代码文件 .h 为后缀的文件:头文件 .i 为后缀的文件:是已经预处理过的C源代码文件 .ii 为后缀的文件:是已经预处理过的C++源代码文件 .o 为后缀的文件:是编译后的目标文件 .s 为后缀的文件:是汇编语言源代码文件 .S 为后缀的文件:是经过预编译的汇编语言源代码文件 常用选项 警.原创 2020-05-10 17:04:48 · 157 阅读 · 0 评论 -
Linux--make基础
(1)编译过程 预处理 gcc -E hello.c -o helle.i 编译 gcc -S hello.i -o hello.s 汇编 gcc -c hello.s -o hello.o 链接 gcc hello.o -o hello (2)make使用 参数 include 用于引入配置文件,makefile文件中配置分开编辑 如直接加入当前目录...原创 2020-05-02 23:24:41 · 190 阅读 · 0 评论