
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 · 331 阅读 · 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 · 182 阅读 · 0 评论 -
Linux的奇怪错误记录
error: ‘for’ loop initial declarations are only allowed in C99 modefor(int i = 0; i < 31; i++){note提示里面已有解决方法note: use option -std=c99 or -std=gnu99 to compile your code所以gcc只需要添加参数: gcc -std=c99 target.cerror: unknown type name ‘sigset_t.原创 2020-07-08 17:20:49 · 1865 阅读 · 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 · 2172 阅读 · 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 · 204 阅读 · 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 · 253 阅读 · 0 评论