Issue
I can build a CMake project with GoogleTest in CLion. But I cannot build it from terminal. I get a bunch of errors when building GoogleTest as a dependency. I also tried to build project without GoogleTest from terminal and it works well.
Platform: Windows 11 x64
The main root CMakeList.txt
cmake_minimum_required (VERSION 3.8)
set(CMAKE_VERBOSE_MAKEFILE ON)
set(COMMON_PROJECT_CPP_STANDARD 20 ON CACHE BOOL "" FORCE)
set(CMAKE_CXX_STANDARD 20)
include(FetchContent)
FetchContent_Declare(
googletest
URL https://github.com/google/googletest/archive/refs/tags/v1.13.0.zip
DOWNLOAD_EXTRACT_TIMESTAMP ON
)
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
FetchContent_MakeAvailable(googletest)
project ("DataStructuresAndAlgorithms")
enable_testing()
add_subdirectory ("src/BubbleSort")
The BubbleSort CMakeList.txt
project("BubbleSort")
add_executable(
${PROJECT_NAME}
"bubblesort.test.cpp"
"bubblesort.h"
)
if (CMAKE_VERSION VERSION_GREATER 3.12)
set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD ${COMMON_PROJECT_CPP_STANDARD})
endif()
# GoogleTest requires at least C++14
target_link_libraries(
${PROJECT_NAME}
GTest::gtest_main
)
include(GoogleTest)
gtest_discover_tests(${PROJECT_NAME})
I copied the commands from my the CLion build output and tried them.
Configure the project
PS D:\0my\pr0jects\CnC++\DataStructuresAndAlgorithms> cmake.exe -DCMAKE_MAKE_PROGRAM="E:/Programs/JetBrains/CLion 2023.1.1/bin/ninja/win/x64/ninja.exe" -DCMAKE_BUILD_TYPE=Debug -DCMAKE_CXX_FLAGS=--coverage -DCMAKE_C_FLAGS=--coverage -G Ninja -S D:/0my/pr0jects/CnC++/DataStructuresAndAlgorithms -B D:/0my/pr0jects/CnC++/DataStructuresAndAlgorithms/mybuild/x64-win-debug-mingw-coverage
-- 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:/Programs/MinGW/bin/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:/Programs/MinGW/bin/c++.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found Python: E:/Programs/Python/Python311/python.exe (found version "3.11.3") found components: Interpreter
-- Configuring done (6.9s)
-- Generating done (0.1s)
-- Build files have been written to: D:/0my/pr0jects/CnC++/DataStructuresAndAlgorithms/mybuild/x64-win-debug-mingw-coverage
Build
PS D:\0my\pr0jects\CnC++\DataStructuresAndAlgorithms> cmake.exe --build D:/0my/pr0jects/CnC++/DataStructuresAndAlgorithms/mybuild/x64-win-debug-mingw-coverage --target all -j 6
[1/24] Building CXX object _deps/googletest-build/googletest/CMakeFiles/gtest_main.dir/src/gtest_main.cc.obj
FAILED: _deps/googletest-build/googletest/CMakeFiles/gtest_main.dir/src/gtest_main.cc.obj
E:\Programs\MinGW\bin\c++.exe -isystem D:/0my/pr0jects/CnC++/DataStructuresAndAlgorithms/mybuild/x64-win-debug-mingw-coverage/_deps/googletest-src/googletest/include -isystem D:/0my/pr0jects/CnC++/DataStructuresAndAlgorithms/mybuild/x64-win-debug-mingw-coverage/_deps/googletest-src/googletest --coverage -g -std=c++2a -Wall -Wshadow -Wno-error=dangling-else -DGTEST_HAS_PTHREAD=0 -fexceptions -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -MD -MT _deps/googletest-build/googletest/CMakeFiles/gtest_main.dir/src/gtest_main.cc.obj -MF _deps\googletest-build\googletest\CMakeFiles\gtest_main.dir\src\gtest_main.cc.obj.d -o _deps/googletest-build/googletest/CMakeFiles/gtest_main.dir/src/gtest_main.cc.obj -c D:/0my/pr0jects/CnC++/DataStructuresAndAlgorithms/mybuild/x64-win-debug-mingw-coverage/_deps/googletest-src/googletest/src/gtest_main.cc
In file included from D:/0my/pr0jects/CnC++/DataStructuresAndAlgorithms/mybuild/x64-win-debug-mingw-coverage/_deps/googletest-src/googletest/include/gtest/gtest-message.h:57,
from D:/0my/pr0jects/CnC++/DataStructuresAndAlgorithms/mybuild/x64-win-debug-mingw-coverage/_deps/googletest-src/googletest/include/gtest/gtest-assertion-result.h:46,
from D:/0my/pr0jects/CnC++/DataStructuresAndAlgorithms/mybuild/x64-win-debug-mingw-coverage/_deps/googletest-src/googletest/include/gtest/gtest.h:64,
from D:/0my/pr0jects/CnC++/DataStructuresAndAlgorithms/mybuild/x64-win-debug-mingw-coverage/_deps/googletest-src/googletest/src/gtest_main.cc:32:
D:/0my/pr0jects/CnC++/DataStructuresAndAlgorithms/mybuild/x64-win-debug-mingw-coverage/_deps/googletest-src/googletest/include/gtest/internal/gtest-port.h:1257:8: error: 'mutex' in namespace 'std' does not name a type
1257 | std::mutex mu_;
| ^~~~~
In file included from D:/0my/pr0jects/CnC++/DataStructuresAndAlgorithms/mybuild/x64-win-debug-mingw-coverage/_deps/googletest-src/googletest/include/gtest/gtest-message.h:57,
from D:/0my/pr0jects/CnC++/DataStructuresAndAlgorithms/mybuild/x64-win-debug-mingw-coverage/_deps/googletest-src/googletest/include/gtest/gtest-assertion-result.h:46,
from D:/0my/pr0jects/CnC++/DataStructuresAndAlgorithms/mybuild/x64-win-debug-mingw-coverage/_deps/googletest-src/googletest/include/gtest/gtest.h:64,
from D:/0my/pr0jects/CnC++/DataStructuresAndAlgorithms/mybuild/x64-win-debug-mingw-coverage/_deps/googletest-src/googletest/src/gtest_main.cc:32:
D:/0my/pr0jects/CnC++/DataStructuresAndAlgorithms/mybuild/x64-win-debug-mingw-coverage/_deps/googletest-src/googletest/include/gtest/internal/gtest-port.h:773:1: note: 'std::mutex' is defined in header '<mutex>'; did you forget to '#include <mutex>'?
772 | #include <mutex> // NOLINT
+++ |+#include <mutex>
773 | #endif // GTEST_IS_THREADSAFE
In file included from D:/0my/pr0jects/CnC++/DataStructuresAndAlgorithms/mybuild/x64-win-debug-mingw-coverage/_deps/googletest-src/googletest/include/gtest/gtest-message.h:57,
from D:/0my/pr0jects/CnC++/DataStructuresAndAlgorithms/mybuild/x64-win-debug-mingw-coverage/_deps/googletest-src/googletest/include/gtest/gtest-assertion-result.h:46,
from D:/0my/pr0jects/CnC++/DataStructuresAndAlgorithms/mybuild/x64-win-debug-mingw-coverage/_deps/googletest-src/googletest/include/gtest/gtest.h:64,
from D:/0my/pr0jects/CnC++/DataStructuresAndAlgorithms/mybuild/x64-win-debug-mingw-coverage/_deps/googletest-src/googletest/src/gtest_main.cc:32:
D:/0my/pr0jects/CnC++/DataStructuresAndAlgorithms/mybuild/x64-win-debug-mingw-coverage/_deps/googletest-src/googletest/include/gtest/internal/gtest-port.h:1258:8: error: 'condition_variable' in namespace 'std' does not name a type
1258 | std::condition_variable cv_;
| ^~~~~~~~~~~~~~~~~~
In file included from D:/0my/pr0jects/CnC++/DataStructuresAndAlgorithms/mybuild/x64-win-debug-mingw-coverage/_deps/googletest-src/googletest/include/gtest/gtest-message.h:57,
from D:/0my/pr0jects/CnC++/DataStructuresAndAlgorithms/mybuild/x64-win-debug-mingw-coverage/_deps/googletest-src/googletest/include/gtest/gtest-assertion-result.h:46,
from D:/0my/pr0jects/CnC++/DataStructuresAndAlgorithms/mybuild/x64-win-debug-mingw-coverage/_deps/googletest-src/googletest/include/gtest/gtest.h:64,
from D:/0my/pr0jects/CnC++/DataStructuresAndAlgorithms/mybuild/x64-win-debug-mingw-coverage/_deps/googletest-src/googletest/src/gtest_main.cc:32:
D:/0my/pr0jects/CnC++/DataStructuresAndAlgorithms/mybuild/x64-win-debug-mingw-coverage/_deps/googletest-src/googletest/include/gtest/internal/gtest-port.h:773:1: note: 'std::condition_variable' is defined in header '<condition_variable>'; did you forget to '#include <condition_variable>'?
772 | #include <mutex> // NOLINT
+++ |+#include <condition_variable>
773 | #endif // GTEST_IS_THREADSAFE
In file included from D:/0my/pr0jects/CnC++/DataStructuresAndAlgorithms/mybuild/x64-win-debug-mingw-coverage/_deps/googletest-src/googletest/include/gtest/gtest-message.h:57,
from D:/0my/pr0jects/CnC++/DataStructuresAndAlgorithms/mybuild/x64-win-debug-mingw-coverage/_deps/googletest-src/googletest/include/gtest/gtest-assertion-result.h:46,
from D:/0my/pr0jects/CnC++/DataStructuresAndAlgorithms/mybuild/x64-win-debug-mingw-coverage/_deps/googletest-src/googletest/include/gtest/gtest.h:64,
from D:/0my/pr0jects/CnC++/DataStructuresAndAlgorithms/mybuild/x64-win-debug-mingw-coverage/_deps/googletest-src/googletest/src/gtest_main.cc:32:
D:/0my/pr0jects/CnC++/DataStructuresAndAlgorithms/mybuild/x64-win-debug-mingw-coverage/_deps/googletest-src/googletest/include/gtest/internal/gtest-port.h: In member function 'void testing::internal::Notification::Notify()':
D:/0my/pr0jects/CnC++/DataStructuresAndAlgorithms/mybuild/x64-win-debug-mingw-coverage/_deps/googletest-src/googletest/include/gtest/internal/gtest-port.h:1244:26: error: 'mutex' is not a member of 'std'
1244 | std::lock_guard<std::mutex> lock(mu_);
| ^~~~~
D:/0my/pr0jects/CnC++/DataStructuresAndAlgorithms/mybuild/x64-win-debug-mingw-coverage/_deps/googletest-src/googletest/include/gtest/internal/gtest-port.h:1244:26: note: 'std::mutex' is defined in header '<mutex>'; did you forget to '#include <mutex>'?
D:/0my/pr0jects/CnC++/DataStructuresAndAlgorithms/mybuild/x64-win-debug-mingw-coverage/_deps/googletest-src/googletest/include/gtest/internal/gtest-port.h:1244:31: error: template argument 1 is invalid
1244 | std::lock_guard<std::mutex> lock(mu_);
| ^
D:/0my/pr0jects/CnC++/DataStructuresAndAlgorithms/mybuild/x64-win-debug-mingw-coverage/_deps/googletest-src/googletest/include/gtest/internal/gtest-port.h:1244:38: error: 'mu_' was not declared in this scope
1244 | std::lock_guard<std::mutex> lock(mu_);
| ^~~
D:/0my/pr0jects/CnC++/DataStructuresAndAlgorithms/mybuild/x64-win-debug-mingw-coverage/_deps/googletest-src/googletest/include/gtest/internal/gtest-port.h:1246:5: error: 'cv_' was not declared in this scope
1246 | cv_.notify_all();
| ^~~
D:/0my/pr0jects/CnC++/DataStructuresAndAlgorithms/mybuild/x64-win-debug-mingw-coverage/_deps/googletest-src/googletest/include/gtest/internal/gtest-port.h: In member function 'void testing::internal::Notification::WaitForNotification()':
D:/0my/pr0jects/CnC++/DataStructuresAndAlgorithms/mybuild/x64-win-debug-mingw-coverage/_deps/googletest-src/googletest/include/gtest/internal/gtest-port.h:1252:27: error: 'mutex' is not a member of 'std'
1252 | std::unique_lock<std::mutex> lock(mu_);
| ^~~~~
D:/0my/pr0jects/CnC++/DataStructuresAndAlgorithms/mybuild/x64-win-debug-mingw-coverage/_deps/googletest-src/googletest/include/gtest/internal/gtest-port.h:1252:27: note: 'std::mutex' is defined in header '<mutex>'; did you forget to '#include <mutex>'?
D:/0my/pr0jects/CnC++/DataStructuresAndAlgorithms/mybuild/x64-win-debug-mingw-coverage/_deps/googletest-src/googletest/include/gtest/internal/gtest-port.h:1252:32: error: template argument 1 is invalid
1252 | std::unique_lock<std::mutex> lock(mu_);
| ^
D:/0my/pr0jects/CnC++/DataStructuresAndAlgorithms/mybuild/x64-win-debug-mingw-coverage/_deps/googletest-src/googletest/include/gtest/internal/gtest-port.h:1252:39: error: 'mu_' was not declared in this scope
1252 | std::unique_lock<std::mutex> lock(mu_);
| ^~~
D:/0my/pr0jects/CnC++/DataStructuresAndAlgorithms/mybuild/x64-win-debug-mingw-coverage/_deps/googletest-src/googletest/include/gtest/internal/gtest-port.h:1253:5: error: 'cv_' was not declared in this scope
1253 | cv_.wait(lock, [this]() { return notified_; });
| ^~~
D:/0my/pr0jects/CnC++/DataStructuresAndAlgorithms/mybuild/x64-win-debug-mingw-coverage/_deps/googletest-src/googletest/include/gtest/internal/gtest-port.h: In function 'int testing::internal::posix::FileNo(FILE*)':
D:/0my/pr0jects/CnC++/DataStructuresAndAlgorithms/mybuild/x64-win-debug-mingw-coverage/_deps/googletest-src/googletest/include/gtest/internal/gtest-port.h:1992:40: error: '_fileno' was not declared in this scope; did you mean 'file'?
1992 | inline int FileNo(FILE* file) { return _fileno(file); }
| ^~~~~~~
| file
D:/0my/pr0jects/CnC++/DataStructuresAndAlgorithms/mybuild/x64-win-debug-mingw-coverage/_deps/googletest-src/googletest/include/gtest/internal/gtest-port.h: In function 'int testing::internal::posix::StrCaseCmp(const char*, const char*)':
D:/0my/pr0jects/CnC++/DataStructuresAndAlgorithms/mybuild/x64-win-debug-mingw-coverage/_deps/googletest-src/googletest/include/gtest/internal/gtest-port.h:2044:10: error: '_stricmp' was not declared in this scope; did you mean 'strncmp'?
2044 | return _stricmp(s1, s2);
| ^~~~~~~~
| strncmp
D:/0my/pr0jects/CnC++/DataStructuresAndAlgorithms/mybuild/x64-win-debug-mingw-coverage/_deps/googletest-src/googletest/include/gtest/internal/gtest-port.h: In function 'char* testing::internal::posix::StrDup(const char*)':
D:/0my/pr0jects/CnC++/DataStructuresAndAlgorithms/mybuild/x64-win-debug-mingw-coverage/_deps/googletest-src/googletest/include/gtest/internal/gtest-port.h:2046:47: error: '_strdup' was not declared in this scope
2046 | inline char* StrDup(const char* src) { return _strdup(src); }
| ^~~~~~~
D:/0my/pr0jects/CnC++/DataStructuresAndAlgorithms/mybuild/x64-win-debug-mingw-coverage/_deps/googletest-src/googletest/include/gtest/internal/gtest-port.h: In function 'FILE* testing::internal::posix::FDOpen(int, const char*)':
D:/0my/pr0jects/CnC++/DataStructuresAndAlgorithms/mybuild/x64-win-debug-mingw-coverage/_deps/googletest-src/googletest/include/gtest/internal/gtest-port.h:2106:56: error: 'fdopen' was not declared in this scope; did you mean 'fopen'?
2106 | inline FILE* FDOpen(int fd, const char* mode) { return fdopen(fd, mode); }
| ^~~~~~
| fopen
[2/24] Building CXX object src/Algorithms/Sort/BubbleSort/CMakeFiles/BubbleSort.dir/bubblesort.test.cpp.obj
FAILED: src/Algorithms/Sort/BubbleSort/CMakeFiles/BubbleSort.dir/bubblesort.test.cpp.obj
E:\Programs\MinGW\bin\c++.exe -ID:/0my/pr0jects/CnC++/DataStructuresAndAlgorithms/src/common -ID:/0my/pr0jects/CnC++/DataStructuresAndAlgorithms/src/Algorithms/Sort/BubbleSort/ON -isystem D:/0my/pr0jects/CnC++/DataStructuresAndAlgorithms/mybuild/x64-win-debug-mingw-coverage/_deps/googletest-src/googletest/include -isystem D:/0my/pr0jects/CnC++/DataStructuresAndAlgorithms/mybuild/x64-win-debug-mingw-coverage/_deps/googletest-src/googletest --coverage -g -std=gnu++2a -MD -MT src/Algorithms/Sort/BubbleSort/CMakeFiles/BubbleSort.dir/bubblesort.test.cpp.obj -MF src\Algorithms\Sort\BubbleSort\CMakeFiles\BubbleSort.dir\bubblesort.test.cpp.obj.d -o src/Algorithms/Sort/BubbleSort/CMakeFiles/BubbleSort.dir/bubblesort.test.cpp.obj -c D:/0my/pr0jects/CnC++/DataStructuresAndAlgorithms/src/Algorithms/Sort/BubbleSort/bubblesort.test.cpp
In file included from D:/0my/pr0jects/CnC++/DataStructuresAndAlgorithms/mybuild/x64-win-debug-mingw-coverage/_deps/googletest-src/googletest/include/gtest/gtest-message.h:57,
from D:/0my/pr0jects/CnC++/DataStructuresAndAlgorithms/mybuild/x64-win-debug-mingw-coverage/_deps/googletest-src/googletest/include/gtest/gtest-assertion-result.h:46,
from D:/0my/pr0jects/CnC++/DataStructuresAndAlgorithms/mybuild/x64-win-debug-mingw-coverage/_deps/googletest-src/googletest/include/gtest/gtest.h:64,
from D:/0my/pr0jects/CnC++/DataStructuresAndAlgorithms/src/Algorithms/Sort/BubbleSort/bubblesort.test.cpp:1:
D:/0my/pr0jects/CnC++/DataStructuresAndAlgorithms/mybuild/x64-win-debug-mingw-coverage/_deps/googletest-src/googletest/include/gtest/internal/gtest-port.h:1257:8: error: 'mutex' in namespace 'std' does not name a type
1257 | std::mutex mu_;
| ^~~~~
In file included from D:/0my/pr0jects/CnC++/DataStructuresAndAlgorithms/mybuild/x64-win-debug-mingw-coverage/_deps/googletest-src/googletest/include/gtest/gtest-message.h:57,
from D:/0my/pr0jects/CnC++/DataStructuresAndAlgorithms/mybuild/x64-win-debug-mingw-coverage/_deps/googletest-src/googletest/include/gtest/gtest-assertion-result.h:46,
from D:/0my/pr0jects/CnC++/DataStructuresAndAlgorithms/mybuild/x64-win-debug-mingw-coverage/_deps/googletest-src/googletest/include/gtest/gtest.h:64,
from D:/0my/pr0jects/CnC++/DataStructuresAndAlgorithms/src/Algorithms/Sort/BubbleSort/bubblesort.test.cpp:1:
D:/0my/pr0jects/CnC++/DataStructuresAndAlgorithms/mybuild/x64-win-debug-mingw-coverage/_deps/googletest-src/googletest/include/gtest/internal/gtest-port.h:773:1: note: 'std::mutex' is defined in header '<mutex>'; did you forget to '#include <mutex>'?
772 | #include <mutex> // NOLINT
+++ |+#include <mutex>
773 | #endif // GTEST_IS_THREADSAFE
In file included from D:/0my/pr0jects/CnC++/DataStructuresAndAlgorithms/mybuild/x64-win-debug-mingw-coverage/_deps/googletest-src/googletest/include/gtest/gtest-message.h:57,
from D:/0my/pr0jects/CnC++/DataStructuresAndAlgorithms/mybuild/x64-win-debug-mingw-coverage/_deps/googletest-src/googletest/include/gtest/gtest-assertion-result.h:46,
from D:/0my/pr0jects/CnC++/DataStructuresAndAlgorithms/mybuild/x64-win-debug-mingw-coverage/_deps/googletest-src/googletest/include/gtest/gtest.h:64,
from D:/0my/pr0jects/CnC++/DataStructuresAndAlgorithms/src/Algorithms/Sort/BubbleSort/bubblesort.test.cpp:1:
D:/0my/pr0jects/CnC++/DataStructuresAndAlgorithms/mybuild/x64-win-debug-mingw-coverage/_deps/googletest-src/googletest/include/gtest/internal/gtest-port.h:1258:8: error: 'condition_variable' in namespace 'std' does not name a type
1258 | std::condition_variable cv_;
| ^~~~~~~~~~~~~~~~~~
In file included from D:/0my/pr0jects/CnC++/DataStructuresAndAlgorithms/mybuild/x64-win-debug-mingw-coverage/_deps/googletest-src/googletest/include/gtest/gtest-message.h:57,
from D:/0my/pr0jects/CnC++/DataStructuresAndAlgorithms/mybuild/x64-win-debug-mingw-coverage/_deps/googletest-src/googletest/include/gtest/gtest-assertion-result.h:46,
from D:/0my/pr0jects/CnC++/DataStructuresAndAlgorithms/mybuild/x64-win-debug-mingw-coverage/_deps/googletest-src/googletest/include/gtest/gtest.h:64,
from D:/0my/pr0jects/CnC++/DataStructuresAndAlgorithms/src/Algorithms/Sort/BubbleSort/bubblesort.test.cpp:1:
D:/0my/pr0jects/CnC++/DataStructuresAndAlgorithms/mybuild/x64-win-debug-mingw-coverage/_deps/googletest-src/googletest/include/gtest/internal/gtest-port.h:773:1: note: 'std::condition_variable' is defined in header '<condition_variable>'; did you forget to '#include <condition_variable>'?
772 | #include <mutex> // NOLINT
+++ |+#include <condition_variable>
773 | #endif // GTEST_IS_THREADSAFE
In file included from D:/0my/pr0jects/CnC++/DataStructuresAndAlgorithms/mybuild/x64-win-debug-mingw-coverage/_deps/googletest-src/googletest/include/gtest/gtest-message.h:57,
from D:/0my/pr0jects/CnC++/DataStructuresAndAlgorithms/mybuild/x64-win-debug-mingw-coverage/_deps/googletest-src/googletest/include/gtest/gtest-assertion-result.h:46,
from D:/0my/pr0jects/CnC++/DataStructuresAndAlgorithms/mybuild/x64-win-debug-mingw-coverage/_deps/googletest-src/googletest/include/gtest/gtest.h:64,
from D:/0my/pr0jects/CnC++/DataStructuresAndAlgorithms/src/Algorithms/Sort/BubbleSort/bubblesort.test.cpp:1:
D:/0my/pr0jects/CnC++/DataStructuresAndAlgorithms/mybuild/x64-win-debug-mingw-coverage/_deps/googletest-src/googletest/include/gtest/internal/gtest-port.h: In member function 'void testing::internal::Notification::Notify()':
D:/0my/pr0jects/CnC++/DataStructuresAndAlgorithms/mybuild/x64-win-debug-mingw-coverage/_deps/googletest-src/googletest/include/gtest/internal/gtest-port.h:1244:26: error: 'mutex' is not a member of 'std'
1244 | std::lock_guard<std::mutex> lock(mu_);
| ^~~~~
D:/0my/pr0jects/CnC++/DataStructuresAndAlgorithms/mybuild/x64-win-debug-mingw-coverage/_deps/googletest-src/googletest/include/gtest/internal/gtest-port.h:1244:26: note: 'std::mutex' is defined in header '<mutex>'; did you forget to '#include <mutex>'?
D:/0my/pr0jects/CnC++/DataStructuresAndAlgorithms/mybuild/x64-win-debug-mingw-coverage/_deps/googletest-src/googletest/include/gtest/internal/gtest-port.h:1244:31: error: template argument 1 is invalid
1244 | std::lock_guard<std::mutex> lock(mu_);
| ^
D:/0my/pr0jects/CnC++/DataStructuresAndAlgorithms/mybuild/x64-win-debug-mingw-coverage/_deps/googletest-src/googletest/include/gtest/internal/gtest-port.h:1244:38: error: 'mu_' was not declared in this scope
1244 | std::lock_guard<std::mutex> lock(mu_);
| ^~~
D:/0my/pr0jects/CnC++/DataStructuresAndAlgorithms/mybuild/x64-win-debug-mingw-coverage/_deps/googletest-src/googletest/include/gtest/internal/gtest-port.h:1246:5: error: 'cv_' was not declared in this scope
1246 | cv_.notify_all();
| ^~~
D:/0my/pr0jects/CnC++/DataStructuresAndAlgorithms/mybuild/x64-win-debug-mingw-coverage/_deps/googletest-src/googletest/include/gtest/internal/gtest-port.h: In member function 'void testing::internal::Notification::WaitForNotification()':
D:/0my/pr0jects/CnC++/DataStructuresAndAlgorithms/mybuild/x64-win-debug-mingw-coverage/_deps/googletest-src/googletest/include/gtest/internal/gtest-port.h:1252:27: error: 'mutex' is not a member of 'std'
1252 | std::unique_lock<std::mutex> lock(mu_);
| ^~~~~
...
ninja: build stopped: subcommand failed.
PS D:\0my\pr0jects\CnC++\DataStructuresAndAlgorithms>
When I try to use the same toolchain as in CLion I got next error. Configure the project
PS D:\0my\pr0jects\CnC++\DataStructuresAndAlgorithms> ."E:/Programs/JetBrains/CLion 2023.1.1/bin/cmake/win/x64/bin/cmake.exe" -DCMAKE_MAKE_PROGRAM="E:/Programs/JetBrains/CLion 2023.1.1/bin/ninja/win/x64/ninja.exe" -DCMAKE_BUILD_TYPE=Debug -DCMAKE_C_COMPILER="E:/Programs/JetBrains/CLion 2023.1.1/bin/mingw/bin/gcc.exe" -DCMAKE_CXX_COMPILER="E:/Programs/JetBrains/CLion 2023.1.1/bin/mingw/bin/g++.exe" -G Ninja -S D:/0my/pr0jects/CnC++/DataStructuresAndAlgorithms -B D:/0my/pr0jects/CnC++/DataStructuresAndAlgorithms/mybuild/x64-win-debug-mingw-coverage
-- The C compiler identification is unknown
-- The CXX compiler identification is unknown
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - failed
-- Check for working C compiler: E:/Programs/JetBrains/CLion 2023.1.1/bin/mingw/bin/gcc.exe
-- Check for working C compiler: E:/Programs/JetBrains/CLion 2023.1.1/bin/mingw/bin/gcc.exe - broken
CMake Error at E:/Programs/JetBrains/CLion 2023.1.1/bin/cmake/win/x64/share/cmake-3.25/Modules/CMakeTestCCompiler.cmake:70 (message):
The C compiler
"E:/Programs/JetBrains/CLion 2023.1.1/bin/mingw/bin/gcc.exe"
is not able to compile a simple test program.
It fails with the following output:
Change Dir: D:/0my/pr0jects/CnC++/DataStructuresAndAlgorithms/mybuild/x64-win-debug-mingw-coverage/CMakeFiles/CMakeScratch/TryCompile-zurrzv
Run Build Command(s):E:/Programs/JetBrains/CLion 2023.1.1/bin/ninja/win/x64/ninja.exe cmTC_dc730 && [1/2] Building C object CMakeFiles\cmTC_dc730.dir\testCCompiler.c.obj
FAILED: CMakeFiles/cmTC_dc730.dir/testCCompiler.c.obj
"E:\Programs\JetBrains\CLion 2023.1.1\bin\mingw\bin\gcc.exe" -o CMakeFiles\cmTC_dc730.dir\testCCompiler.c.obj -c D:\0my\pr0jects\CnC++\DataStructuresAndAlgorithms\mybuild\x64-win-debug-mingw-coverage\CMakeFiles\CMakeScratch\TryCompile-zurrzv\testCCompiler.c
ninja: build stopped: subcommand failed.
CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
mybuild/x64-win-debug-mingw-coverage/_deps/googletest-src/CMakeLists.txt:18 (project)
-- Configuring incomplete, errors occurred!
See also "D:/0my/pr0jects/CnC++/DataStructuresAndAlgorithms/mybuild/x64-win-debug-mingw-coverage/CMakeFiles/CMakeOutput.log".
See also "D:/0my/pr0jects/CnC++/DataStructuresAndAlgorithms/mybuild/x64-win-debug-mingw-coverage/CMakeFiles/CMakeError.log".
UPD: My main problem/goal is to compile a CLion project using GoogleTest from the terminal. How it will be done, what toolchain to use - it doesn't matter to me.
Why is this post rated as unclear there is not one specific suggestion to solve the problem or question, what exactly is unclear?
Solution
From the error message:
error: 'mutex' in namespace 'std' does not name a type
This suggests that your system-wide installation of MinGW wasn's installed with pthreads support. See C++ mutex in namespace std does not name a type
Answered By - RAM Answer Checked By - Candace Johnson (WPSolving Volunteer)