Настройте Google Test с Mingw64 на windows 10 (C язык) - PullRequest
0 голосов
/ 06 января 2020

Я использую тест Google для проверки C кода на Windows, но при этом возникают некоторые проблемы. Я уже установил Cmake, MingW64, python и установил путь для установленных пакетов в Переменной среды. Затем я загружаю https://github.com/google/googletest пример и следую за линией гильдии, чтобы запустить его.

Шаги как это:

1. Open cmd on windows
2. cd xxx/googletest-master/googletest
3. cmake -G "MinGW Makefiles" CMakeLists.txt

Результат, как это:

C:\Users\TIEN\Desktop\UNITTEST\googletest-master\googletest>cmake -G "MinGW Makefiles" CMakeLists.txt
CMake Warning at CMakeLists.txt:54 (project):
  VERSION keyword not followed by a value or was followed by a value that
  expanded to nothing.


-- The CXX compiler identification is GNU 4.9.2
-- The C compiler identification is GNU 4.9.2
-- Check for working CXX compiler: C:/Program Files (x86)/Dev-Cpp/MinGW64/bin/g++.exe
-- Check for working CXX compiler: C:/Program Files (x86)/Dev-Cpp/MinGW64/bin/g++.exe -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Check for working C compiler: C:/Program Files (x86)/Dev-Cpp/MinGW64/bin/gcc.exe
-- Check for working C compiler: C:/Program Files (x86)/Dev-Cpp/MinGW64/bin/gcc.exe -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Found PythonInterp: C:/Program Files (x86)/Dev-Cpp/MinGW64/bin/python.exe (found version "2.7.8")
-- Configuring done
-- Generating done
-- Build files have been written to: C:/Users/TIEN/Desktop/UNITTEST/googletest-master/googletest
4. mingw32-make.exe

Результат, как это:

C:\Users\TIEN\Desktop\UNITTEST\googletest-master\googletest>mingw32-make.exe
Scanning dependencies of target gtest
[ 25%] Building CXX object CMakeFiles/gtest.dir/src/gtest-all.cc.obj
In file included from C:/PROGRA~2/Dev-Cpp/MinGW64/lib/gcc/x86_64-w64-mingw32/4.9.2/include/c++/type_traits:35:0,
                 from C:/Users/TIEN/Desktop/UNITTEST/googletest-master/googletest/include/gtest/gtest.h:59,
                 from C:\Users\TIEN\Desktop\UNITTEST\googletest-master\googletest\src\gtest-all.cc:38:
C:/PROGRA~2/Dev-Cpp/MinGW64/lib/gcc/x86_64-w64-mingw32/4.9.2/include/c++/bits/c++0x_warning.h:32:2: error: #error This file requires compiler and library support for the ISO C++ 2011 standard. This support is currently experimental, and must be enabled with the -std=c++11 or -std=gnu++11 compiler options.
 #error This file requires compiler and library support for the \
  ^
In file included from C:/Users/TIEN/Desktop/UNITTEST/googletest-master/googletest/include/gtest/internal/gtest-internal.h:40:0,
                 from C:/Users/TIEN/Desktop/UNITTEST/googletest-master/googletest/include/gtest/gtest.h:62,
                 from C:\Users\TIEN\Desktop\UNITTEST\googletest-master\googletest\src\gtest-all.cc:38:
C:/Users/TIEN/Desktop/UNITTEST/googletest-master/googletest/include/gtest/internal/gtest-port.h:972:1: error: identifier 'nullptr' is a keyword in C++11 [-Werror=c++0x-compat]
 inline void FlushInfoLog() { fflush(nullptr); }
 ^
C:/Users/TIEN/Desktop/UNITTEST/googletest-master/googletest/include/gtest/internal/gtest-port.h:2104:1: error: identifier 'constexpr' is a keyword in C++11 [-Werror=c++0x-compat]
 constexpr BiggestInt kMaxBiggestInt = (std::numeric_limits<BiggestInt>::max)();
 ^
In file included from C:/Users/TIEN/Desktop/UNITTEST/googletest-master/googletest/include/gtest/gtest.h:62:0,
                 from C:\Users\TIEN\Desktop\UNITTEST\googletest-master\googletest\src\gtest-all.cc:38:
........................................................
........................................................
C:/Users/TIEN/Desktop/UNITTEST/googletest-master/googletest/src/gtest.cc: At global scope:
C:/Users/TIEN/Desktop/UNITTEST/googletest-master/googletest/src/gtest.cc:189:14: error: 'FILE* testing::internal::OpenFileForWriting(const string&)' defined but not used [-Werror=unused-function]
 static FILE* OpenFileForWriting(const std::string& output_file) {
              ^
C:/Users/TIEN/Desktop/UNITTEST/googletest-master/googletest/src/gtest.cc:357:13: error: 'bool testing::internal::GTestIsInitialized()' defined but not used [-Werror=unused-function]
 static bool GTestIsInitialized() { return GetArgvs().size() > 0; }
             ^
cc1plus.exe: all warnings being treated as errors
CMakeFiles\gtest.dir\build.make:62: recipe for target 'CMakeFiles/gtest.dir/src/gtest-all.cc.obj' failed
mingw32-make.exe[2]: *** [CMakeFiles/gtest.dir/src/gtest-all.cc.obj] Error 1
CMakeFiles\Makefile2:76: recipe for target 'CMakeFiles/gtest.dir/all' failed
mingw32-make.exe[1]: *** [CMakeFiles/gtest.dir/all] Error 2
Makefile:82: recipe for target 'all' failed
mingw32-make.exe: *** [all] Error 2

Это происходит ошибки и не может работать Тест Google, как я могу решить эту проблему?

...