# Performing C SOURCE FILE Test CMAKE\_HAVE\_LIBC\_PTHREAD failed with the following output:

**URL:** https://discourse.cmake.org/t/performing-c-source-file-test-cmake-have-libc-pthread-failed-with-the-following-output/3253
**Category:** Usage
**Tags:** os:windows
**Created:** [May 3, 2021, 3:12pm UTC](https://discourse.cmake.org/t/performing-c-source-file-test-cmake-have-libc-pthread-failed-with-the-following-output/3253 "2021-05-03T15:12:30Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![Yifan\_Liu](https://discourse.cmake.org/user_avatar/discourse.cmake.org/yifan_liu/32/1423_2.png) [@Yifan\_Liu](https://discourse.cmake.org/u/Yifan_Liu)
#### Post date: [May 3, 2021, 3:12pm UTC](https://discourse.cmake.org/t/performing-c-source-file-test-cmake-have-libc-pthread-failed-with-the-following-output/3253/1 "2021-05-03T15:12:30Z")

</div>

Hi, I am trying to create a c++ project from existing source, but I am stuck with an error during the pre-build process and I can’t figure out what leads to it. The first one is a CMakeError, which is shown below:

> Performing C SOURCE FILE Test CMAKE\_HAVE\_LIBC\_PTHREAD failed with the following output:  
> Change Dir: E:/Yifan/Hiwi-FSD/FluCo1/Libraries/fsd-libs/trunk/build-dev/CMakeFiles/CMakeTmp
> 
> Run Build Command(s):C:/MinGW/msys/1.0/bin/make.exe -f Makefile cmTC\_394d9/fast && /usr/bin/make -f CMakeFiles/cmTC\_394d9.dir/build.make CMakeFiles/cmTC\_394d9.dir/build  
> make[1]: Entering directory `/e/Yifan/Hiwi-FSD/FluCo1/Libraries/fsd-libs/trunk/build-dev/CMakeFiles/CMakeTmp’  
> Building C object CMakeFiles/cmTC\_394d9.dir/src.c.obj
> 
> E:/Yifan/Hiwi-FSD/FluCo1/Libraries/fsd-libs/trunk/nbproject/private/tools/localhost/MinGW/gcc.exe -DCMAKE\_HAVE\_LIBC\_PTHREAD -o CMakeFiles/cmTC\_394d9.dir/src.c.obj -c E:/Yifan/Hiwi-FSD/FluCo1/Libraries/fsd-libs/trunk/build-dev/CMakeFiles/CMakeTmp/src.c  
> E:/Yifan/Hiwi-FSD/FluCo1/Libraries/fsd-libs/trunk/build-dev/CMakeFiles/CMakeTmp/src.c: In function ‘main’:  
> E:/Yifan/Hiwi-FSD/FluCo1/Libraries/fsd-libs/trunk/build-dev/CMakeFiles/CMakeTmp/src.c:15:3: warning: implicit declaration of function ‘pthread\_atfork’; did you mean ‘pthread\_join’? [-Wimplicit-function-declaration]  
> 15 | pthread\_atfork(NULL, NULL, NULL);  
> | ^ ~~~~~~~~~~~~~  
> | pthread\_join  
> Linking C executable cmTC\_394d9.exe
> 
> “C:/Program Files/CMake/bin/cmake.exe” -E rm -f CMakeFiles/cmTC\_394d9.dir/objects.a  
> C:/MinGW/bin/ar.exe cr CMakeFiles/cmTC\_394d9.dir/objects.a @CMakeFiles/cmTC\_394d9.dir/objects1.rsp  
> E:/Yifan/Hiwi-FSD/FluCo1/Libraries/fsd-libs/trunk/nbproject/private/tools/localhost/MinGW/gcc.exe -Wl,–whole-archive CMakeFiles/cmTC\_394d9.dir/objects.a -Wl,–no-whole-archive -o cmTC\_394d9.exe -Wl,–out-implib,libcmTC\_394d9.dll.a -Wl,–major-image-version,0,–minor-image-version,0 @CMakeFiles/cmTC\_394d9.dir/linklibs.rsp  
> c:/mingw/bin/…/lib/gcc/mingw32/9.2.0/…/…/…/…/mingw32/bin/ld.exe: CMakeFiles/cmTC\_394d9.dir/objects.a(src.c.obj):src.c:(.text+0x36): undefined reference to `\_imp\_\_pthread\_create’
> 
> c:/mingw/bin/…/lib/gcc/mingw32/9.2.0/…/…/…/…/mingw32/bin/ld.exe: CMakeFiles/cmTC\_394d9.dir/objects.a(src.c.obj):src.c:(.text+0x4c): undefined reference to `\_imp\_\_pthread\_detach’
> 
> c:/mingw/bin/…/lib/gcc/mingw32/9.2.0/…/…/…/…/mingw32/bin/ld.exe: CMakeFiles/cmTC\_394d9.dir/objects.a(src.c.obj):src.c:(.text+0x62): undefined reference to `\_imp\_\_pthread\_cancel’
> 
> c:/mingw/bin/…/lib/gcc/mingw32/9.2.0/…/…/…/…/mingw32/bin/ld.exe: CMakeFiles/cmTC\_394d9.dir/objects.a(src.c.obj):src.c:(.text+0x80): undefined reference to `\_imp\_\_pthread\_join’
> 
> c:/mingw/bin/…/lib/gcc/mingw32/9.2.0/…/…/…/…/mingw32/bin/ld.exe: CMakeFiles/cmTC\_394d9.dir/objects.a(src.c.obj):src.c:(.text+0x9e): undefined reference to `pthread\_atfork’
> 
> c:/mingw/bin/…/lib/gcc/mingw32/9.2.0/…/…/…/…/mingw32/bin/ld.exe: CMakeFiles/cmTC\_394d9.dir/objects.a(src.c.obj):src.c:(.text+0xaa): undefined reference to `\_imp\_\_pthread\_exit’
> 
> collect2.exe: error: ld returned 1 exit status  
> make[1]: \*\*\* [cmTC\_394d9.exe] Error 1  
> make[1]: Leaving directory `/e/Yifan/Hiwi-FSD/FluCo1/Libraries/fsd-libs/trunk/build-dev/CMakeFiles/CMakeTmp’  
> make: \*\*\* [cmTC\_394d9/fast] Error 2
> 
> Source file was:  
> #include \<pthread.h\>
> 
> static void\* test\_func(void\* data)  
> {  
> return data;  
> }
> 
> int main(void)  
> {  
> pthread\_t thread;  
> pthread\_create(&thread, NULL, test\_func, NULL);  
> pthread\_detach(thread);  
> pthread\_cancel(thread);  
> pthread\_join(thread, NULL);  
> pthread\_atfork(NULL, NULL, NULL);  
> pthread\_exit(NULL);
> 
> return 0;  
> }

**And the terminal output is:**

> cd ‘E:\Yifan\Hiwi-FSD\FluCo1\Libraries\fsd-libs\trunk\build-dev’  
> C:/Program Files/CMake/bin/cmake.exe -G Unix Makefiles -DCMAKE\_BUILD\_TYPE=Debug -DCMAKE\_C\_COMPILER=E:/Yifan/Hiwi-FSD/FluCo1/Libraries/fsd-libs/trunk/nbproject/private/tools/localhost/MinGW/gcc.exe -DCMAKE\_CXX\_COMPILER=E:/Yifan/Hiwi-FSD/FluCo1/Libraries/fsd-libs/trunk/nbproject/private/tools/localhost/MinGW/g++.exe -DCMAKE\_C\_FLAGS\_DEBUG=-g3 -gdwarf-2 -DCMAKE\_CXX\_FLAGS\_DEBUG=-g3 -gdwarf-2 -DCMAKE\_EXPORT\_COMPILE\_COMMANDS=ON -DPROJECT\_SUFFIX=-dev …  
> – The C compiler identification is GNU 9.2.0  
> – The CXX compiler identification is GNU 9.2.0  
> – Detecting C compiler ABI info  
> – Detecting C compiler ABI info - done  
> – Check for working C compiler: E:/Yifan/Hiwi-FSD/FluCo1/Libraries/fsd-libs/trunk/nbproject/private/tools/localhost/MinGW/gcc.exe - skipped  
> – Detecting C compile features  
> – Detecting C compile features - done  
> – Detecting CXX compiler ABI info  
> – Detecting CXX compiler ABI info - done  
> – Check for working CXX compiler: E:/Yifan/Hiwi-FSD/FluCo1/Libraries/fsd-libs/trunk/nbproject/private/tools/localhost/MinGW/g++.exe - skipped  
> – Detecting CXX compile features  
> – Detecting CXX compile features - done  
> – The cmake will use build type Debug  
> – libfsd-io-dev version is 1.0+  
> – Install include dir include/fsd-io-dev  
> – fsd-io-dev PROJECT\_SOURCE\_DIR = E:/Yifan/Hiwi-FSD/FluCo1/Libraries/fsd-libs/trunk/IO  
> – fsd-io-dev Build directory = E:/Yifan/Hiwi-FSD/FluCo1/Libraries/fsd-libs/trunk/build-dev  
> – Found PkgConfig: C:/MinGW/bin/pkg-config.exe (found version “0.26”)  
> – Checking for one of the modules ‘openssl’  
> CMake Error at C:/Program Files/CMake/share/cmake-3.20/Modules/FindPkgConfig.cmake:843 (message):  
> None of the required ‘openssl’ found  
> Call Stack (most recent call first):  
> IO/CMakeLists.txt:47 (pkg\_search\_module)
> 
> – Looking for pthread.h  
> – Looking for pthread.h - found  
> – Performing Test CMAKE\_HAVE\_LIBC\_PTHREAD  
> – Performing Test CMAKE\_HAVE\_LIBC\_PTHREAD - Failed  
> – Check if compiler accepts -pthread  
> – Check if compiler accepts -pthread - yes  
> – Found Threads: TRUE  
> – libfsd-log-dev version is 1.0+  
> – fsd-log-dev PROJECT\_SOURCE\_DIR = E:/Yifan/Hiwi-FSD/FluCo1/Libraries/fsd-libs/trunk/Log  
> – fsd-log-dev Build directory = E:/Yifan/Hiwi-FSD/FluCo1/Libraries/fsd-libs/trunk/build-dev  
> – Install include dir include/fsd-log-dev  
> – libfsd-math-dev version is 1.0+  
> – fsd-math-dev PROJECT\_SOURCE\_DIR = E:/Yifan/Hiwi-FSD/FluCo1/Libraries/fsd-libs/trunk/Math  
> – fsd-math-dev Build directory = E:/Yifan/Hiwi-FSD/FluCo1/Libraries/fsd-libs/trunk/build-dev  
> – Configuring incomplete, errors occurred!  
> See also “E:/Yifan/Hiwi-FSD/FluCo1/Libraries/fsd-libs/trunk/build-dev/CMakeFiles/CMakeOutput.log”.  
> See also “E:/Yifan/Hiwi-FSD/FluCo1/Libraries/fsd-libs/trunk/build-dev/CMakeFiles/CMakeError.log”.
> 
> PRE-BUILD FAILED (exit value 1, total time: 8s)

Can anyone please help me about it? If you need any further information, I would be glad to offer. I have totally no idea about what’s the cause and where may I find it. I would really appreciate your help, thanksss!!

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)
#### Post date: [May 3, 2021, 3:28pm UTC](https://discourse.cmake.org/t/performing-c-source-file-test-cmake-have-libc-pthread-failed-with-the-following-output/3253/2 "2021-05-03T15:28:23Z")

</div>

It looks like you’re missing OpenSSL headers for MinGW. Does installing the package for that help (I’m not sure what the name would be, but maybe `libssl-devel`, `libssl-dev`, `openssl-devel`, or the like)?

---

<div class="post-metadata">

### Author: ![Yifan\_Liu](https://discourse.cmake.org/user_avatar/discourse.cmake.org/yifan_liu/32/1423_2.png) [@Yifan\_Liu](https://discourse.cmake.org/u/Yifan_Liu)
#### Post date: [May 4, 2021, 12:40am UTC](https://discourse.cmake.org/t/performing-c-source-file-test-cmake-have-libc-pthread-failed-with-the-following-output/3253/3 "2021-05-04T00:40:39Z")

</div>

Hi, thank you very much for your reply. I have installed OpenSSL and also added the path as an environment variable. But I think maybe `libssl-devel`, `libssl-dev` , `openssl-devel` are the solutions and I haven’t installed them. However, after I searched in Google, they seem all to be packages for Linux system, can you offer some suggestions on how to install them in Windows? Thanks 🙂

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)
#### Post date: [May 4, 2021, 9:57am UTC](https://discourse.cmake.org/t/performing-c-source-file-test-cmake-have-libc-pthread-failed-with-the-following-output/3253/4 "2021-05-04T09:57:20Z")

</div>

IIRC, MinGW has a package manager similar to Linux. However, maybe I’m thinking of MSYS2 here. [Qt’s instructions](https://wiki.qt.io/Compiling_OpenSSL_with_MinGW) seem relevant here though.

---

<div class="post-metadata">

### Author: ![Yifan\_Liu](https://discourse.cmake.org/user_avatar/discourse.cmake.org/yifan_liu/32/1423_2.png) [@Yifan\_Liu](https://discourse.cmake.org/u/Yifan_Liu)
#### Post date: [May 7, 2021, 9:42am UTC](https://discourse.cmake.org/t/performing-c-source-file-test-cmake-have-libc-pthread-failed-with-the-following-output/3253/5 "2021-05-07T09:42:41Z")

</div>

Hi, I have installed MSYS2 and set it as my default tool collection. Then the problem is solved!!! Thank you very much for your advices 😀
