makefile的杂七杂八

-fPIC -shared 生成动态链接库 .so
ar rc 生成静态连接库 .a

参数:“-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

-L /home/hello/lib表示将/home/hello/lib目录作为第一个寻找库文件的目录,寻找的顺序是:/home/hello/lib-->/lib-->/usr/lib-->/usr/local/lib

-lworld表示在上面的lib的路径中寻找libworld.so动态库文件(如果gcc编译选项中加入了“-static”表示寻找libworld.a静态库文件)

关于 -pthread-lpthread

$ man gcc | grep pthread
           -mvxworks -G num -pthread
           -mno-unaligned-doubles -mv8plus -mno-v8plus -mvis -mno-vis -threads -pthreads
           -pthread
           implies -pthread, and thus is only supported on targets that have support for
           -pthread.
           implies -pthread, and thus is only supported on targets that have support for
           -pthread.
           option and the -pthread option are incompatible.
       -pthread
           Adds support for multithreading with the pthreads library. This option sets flags for
       -pthreads
       -pthread
           This is a synonym for -pthreads.
 $ man gcc | grep lpthread
 $

gcc 4.5.2中已经没有了关于 -lpthread的介绍了。所以以后的多线程编译应该用-pthread,而不是-lpthread。

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值