(2) 一条命令完成以上操作:
A.执行清屏命令: clear B.输入命令生成可执行程序myprog : gcc star.c hello.c -o myprog C
.
执
行
程
序
myprog,
其
命
令
是: ./myprog : D.执行情况截图:
3.常见选项的应用 (1)写出-Wll选项的作用:
允许发出gcc提供的所有有用的报警信息
(2)写出-w选项的作用: 关闭所有警告信息
(3)写出-v选项的作用并执行:
打印出编译器内部编译各过程的命令行信息和编译器的版本
(4)测试选项,列出结果:
[root@localhost 01_hello]# gcc star.c hello.c -o myprog
[root@localhost 01_hello]# gcc -w star.c hello.c -o myprog
[root@localhost 01_hello]# gcc -Wall star.c hello.c -o myprog
4.使用动态库
(1)[root@localhost 01_hello]# gcc -c -fpic hello.c
[root@localhost 01_hello]# ls
(2)[root@localhost 01_hello]# gcc -shared -s -o libhello.so hello.o
[root@localhost 01_hello]# ls
(3)注意libhello.so库文件的命名格式,(1)(2)也可以用下边命令替代
gcc -fpic -shared -s hello.c -o libhello.so
(4)[root@localhost 01_hello]# cp libhello.so /usr/lib
注意/usr/lib为用户库自动搜索路径
(5)[root@localhost 01_hello]# gcc -lhello star.c -o mystar [root@localhost 01_hello]# ldd mystar
libhello.so => /usr/lib/libhello.so (0x4002d000) libc.so.6 => /lib/tls/libc.so.6 (0x42000000) /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x40000000) [root@localhost 01_hello]# ./mystar * *** ***** *******

