gcc编译程序时,可能会用到“-I”(大写i),“-L”(大写l),“-l”(小写l)等参数,下面做个记录:
例:
gcc -o hello hello.c -I /home/hello/include -L /home/hello/lib -lworld (静态库和动态库一样的用法)
上面这句表示在编译hello.c时:
头文件:
-I /home/hello/include表示将/home/hello/include目录作为第一个寻找头文件的目录,
寻找的顺序是:/home/hello/include-- >/usr/include-->/usr/local/include
lib库:
-L /home/hello/lib表示将/home/hello/lib目录作为第一个寻找库文件的目录,
寻找的顺序是:/home/hello/lib-->/lib-->/usr/lib-->/usr/local/lib
注意事项:
1、-lword 表示 libworld.so 或 libworld.a ,有的系统支持-llibword,有的则不支持
2、关于-static选项: -lworld表示在上面的lib的路径中寻找libworld.so动态库文件或静态库libworld.a(如果gcc编译选项中加入了“-static”表示强制使用libworld.a静态库文件)