Linux高级编程学习随笔
I.第一章
g++,c++编译器
gcc,c编译器
编译选项:
-c 编译
-I 头文件所在目录
-02 优化级别
-o 输出文件
-l 连接库文件名
-L 连接库文件所在目录
例:g++ -o reciprocal main.o reciprocal.o -L/usr/local/lib/pam -lpam
1.3 Automating the Process with GNU Make
例子:
reciprocal: main.o reciprocal.o
g++ $(CFLAGS) -o reciprocal main.o reciprocal.o
main.o: main.c reciprocal.hpp
gcc $(CFLAGS) -c main.c
reciprocal.o: reciprocal.cpp reciprocal.hpp
g++ $(CFLAGS) -c reciprocal.cpp
clean: rm -f *.o reciprocal
第一项是输出的文件名,包括中间文件和最终文件,后面接着依赖文件,下面一行是如何生成该文件
最后clean为清除所有的文件。
The $(CFLAGS) is a make variable
例子:
% make clean
rm -f *.o reciprocal
% make CFLAGS=-O2
gcc -O2 -c main.c
g++ -O2 -c reciprocal.cpp
g++ -O2 -o reciprocal main.o reciprocal.o
1.4.2 Running GDB
run 运行程序
print 打印变量
break 增加断点
next 每语句执行
step 单步执行
1.5.1 Man Pages
man -k keyword 快速查询
浙公网安备 33010602011771号