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

后端 未结 2 1551
夕颜
夕颜 2021-01-19 05:24

I am trying to include #include in my project which uses CLion but I am cannot use it directly. Is there any specific way to include pthread t

相关标签:
2条回答
  • 2021-01-19 06:08

    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.

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

    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.

    0 讨论(0)
  • 2021-01-19 06:15

    Add -lpthread flag to the compilation, i.e:

     gcc foo.c -lpthread
    

    more info here: Why do you need '-lpthread'?

    0 讨论(0)
提交回复
热议问题