--- -pthread 和 -lpthread 区别

965阅读 0评论2010-10-25 bzhao
分类:LINUX


在网上搜索都一直没有发现这个问题的解释!

---几天在新闻组上看到的帖子如下:
  也是我一直没时间搞清楚的东西

by Lew Pitcher lpitcher@teksavvy.com
In GCC, the -pthread (aka -pthreads) option manages both the compiler
preprocessor /and/ linker to enable compilation with Posix threads. The
preprocessor will define/enable/use Posix threads versions of some macros
(or perform conditional compilation to enable Posix threads logic), and the
linker will specifically link the resultant object against libpthread

However, -lpthread simply tells the linker to attempt to resolve any
external references against the libpthread library, in the same way
that -lm tells the linker to attempt to resolve any external references
against the libm library. For -lpthread, your code might not contain
external references to libpthread, even if you wrote Posix thread code,
because the critical macros haven't been switched on.



上一篇:---如果Xwindow不能启动
下一篇:---改Ubuntu字体为Windows字体设置