永发信息网

Linux gcc 编译参数问题

答案:4  悬赏:70  手机版
解决时间 2021-01-23 21:08
  • 提问者网友:暗中人
  • 2021-01-23 16:36
gcc -lpthread file
(file是用到线程的程序)
-lpthread 参数到底啥意思?用到线程的程序加这参数啥意思?
最佳答案
  • 五星知识达人网友:不如潦草
  • 2021-01-23 18:11
-l 使用库。
这个库的名字是 pthread 。

POSIX 线程是:线程的 POSIX标准,定义了创建和操纵线程的一套 API。
实现 POSIX 线程标准的库常被称作 Pthreads,一般用于 Unix-like POSIX 系统,如 Linux、 Solaris,但是 Microsoft Windows上的实现也存在,例如, pthreads-w32可以用于支持 Pthread API M的子集 [1]。

以上部分文字出自维基百科,故本回答的文字基于GNU自由文档许可证之条款下发布。
另外抗议百度知道封杀维基百科的连接。
全部回答
  • 1楼网友:患得患失的劫
  • 2021-01-23 20:13
-l是指定库文件名
  • 2楼网友:深街酒徒
  • 2021-01-23 19:43
-lpthread means: link with pthread static library (I think which is a *.so file). I think for the first instance you do not need to figure out what does this *really* mean; but if your programme uses functions with thread, (such as pthread_create(), pthread_join(), etc), you need to compile with this "-lpthread" option. Otherwise your linker ("ld" in Linux) will complain: "could not find reference to pthread_create()" or something...
  • 3楼网友:十鸦
  • 2021-01-23 19:29
使用库
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯