如何在Windows中使用MinGW的CLion中的C项目中使用pthread头文件 [英] How to use pthread header file in C project in CLion which uses MinGW in windows
问题描述
我正在尝试将 #include <pthread.h>
包含在我使用 CLion 的项目中,但我不能直接使用它.有没有什么特定的方法可以将 pthread 包含到 C 项目中?
I am trying to include #include <pthread.h>
in my project which uses CLion but I am cannot use it directly. Is there any specific way to include pthread to a C project?
推荐答案
我终于想出了一个解决方案.由于我使用的是 MinGW,因此我使用了 MinGW 安装管理器并安装了需要在 CLion 中执行 pthreads 和 openmp 相关任务的软件包.这是程序.
I finally came up with a solution. Since I am using MinGW I Used MinGW installation manager and install packages that need to execute pthreads and openmp related tasks in CLion. Here is the procedure.
打开安装管理器后,进入所有包,选择使用 mingw32-pthreads-w32 命名的包并选择它们进行安装.
After opening the installation manager go to all packages and select the select packages named using mingw32-pthreads-w32 and select them for installation.
然后转到安装 -> 应用更改以安装新软件包.您可以在 c 或 c++ 程序中使用 pthread.h 和 omp.h,没有任何问题.
Then go to the installtion -> Apply changes to install new packages. The you can use pthread.h and omp.h inside your c or c++ program without any problem.
这篇关于如何在Windows中使用MinGW的CLion中的C项目中使用pthread头文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!