$@表示目标,$^表示依赖列表 $<是第一个
输出重定向
其中0 表示键盘输入 1表示屏幕输出 2表示错误输出
make -f qhsvrall_491.lnx > 491temp.txt 2>&1 &
cat 491temp.txt | grep "\[-" > left.txt
// 截取文件行
sed -n '/01:10:00/, /01:20:00/p' 20141225.log >>tmp.log
这里是gcc命令行中给assembler, preprocessor, linker传递option的具体关键字列表:
-Wa,<options> Pass comma-separated <options> on to the assembler
-Wp,<options> Pass comma-separated <options> on to the preprocessor
-Wl,<options> Pass comma-separated <options> on to the linker
1) 编译参数中可以指定,运行时库查找的目录用下面标记
-Wl,-rpath=
gcc -o test test.c -I. -L. -la -Wl,-rpath=.
rpath链接选项主要有两个功能:
(1)程序运行时,优先到rpath指定的目录去寻找依赖库
(2)程序链接时,在指定的目录中,隐式的链接那些动态库所需要的链接库
2) rpath and -rpath-link :
The difference between -rpath and -rpath-link is that directories specified
by -rpath options are included in the executable and used at runtime,
whereas the -rpath-link option is only effective at link time.
3) 库的动态链接和静态链接:
mysql和另一些自有库静态链接,glibc,libstdc++等一些常见的基础库动态链接。
-Wl,-dn -L/usr/local/mysql/lib/ -lmysqlclient -Wl,-dy -lpthread -ldl -lcrypt
4) 静态链接stdc++,静态链接系统库
ln -s `g++ -print-file-name=libstdc++.a`
-L. -static-libgcc -lstdc++ -static
// 静态库
gcc -c hello.c
ar crv libmyhello.a hello.o
gcc main.c libmyhello.a -o main
静态编译:-static
// 动态库
gcc -c hello.c
gcc -shared -fPCI -o libmyhello.so hello.o
gcc -o hello main.c -L. -lmyhello
-shared 该选项指定生成动态连接库(让连接器生成T类型的导出符号表,有时候也生成弱连接W类型的导出符号),不用该标志外部程序无法连接。相当于一个可执行文件
-fPIC:表示编译为位置独立的代码,不用此选项的话编译后的代码是位置相关的所以动态载入时是通过代码拷贝的方式来满足不同进程的需要,而不能达到真正代码段共享的目的。
动态库的搜索路径搜索的先后顺序是:
1.编译目标代码时指定的动态库搜索路径;
2.环境变量LD_LIBRARY_PATH指定的动态库搜索路径;
3.配置文件/etc/ld.so.conf中指定的动态库搜索路径;
4.默认的动态库搜索路径/lib /usr/lib。
5.安装
// 配置
../configure --prefix=NEWGCC --enable-checking=release --enable-languages=c,c++ --disable-multilib
// 4个线程编译
make -j4
// 安装
make install
// 配置环境变量
6.编译静态库到当前程序或库中,如果不成功,可以加上-Wl,--whole-archive,把整个静态库里面的内容加进来
-Wl,--whole-archive -lyourliba -Wl,--no-whole-archive
7.tcpdump命令
tcpdump -i any -n port 9382 and host 192.168.80.3 -w data.pcap
8.gdb调试
bt:查看调用堆栈
frame:进入堆栈语句,查看具体参数和信息