繁体   English   中英

如何在 CLion 的 C 项目中使用 pthread header 文件,该项目在 windows 中使用 MinGW

[英]How to use pthread header file in C project in CLion which uses MinGW in windows

我正在尝试在使用 CLion 的项目中包含#include <pthread.h> ,但我不能直接使用它。 是否有任何特定方法可以将 pthread 包含到 C 项目中?

我终于想出了一个解决方案。 由于我使用的是 MinGW,我使用了 MinGW 安装管理器并安装了需要在 CLion 中执行 pthreads 和 openmp 相关任务的包。 这是程序。

After opening the installation manager go to all packages and select the select packages named using mingw32-pthreads-w32 and select them for installation.

在此处输入图像描述

然后 go 到 installtion -> Apply changes to install new packages。 您可以在 c 或 c++ 程序中使用 pthread.h 和 omp.h 没有任何问题。

在编译中添加-lpthread标志,即:

 gcc foo.c -lpthread

更多信息在这里: 你为什么需要'-lpthread'?

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM