【发布时间】:2019-08-19 11:57:35
【问题描述】:
这是我目前的环境。 Windows 10 64 位、MinGW、CMake 3.15.2、Python 3.7。 我从https://github.com/google/googletest下载了googletest。
我运行了cmake,输出如下。
C:\googletest-master>cd build
C:\googletest-master\build>cmake ../ -G "MinGW Makefiles"
-- The C compiler identification is GNU 8.2.0
-- The CXX compiler identification is GNU 8.2.0
-- Check for working C compiler: C:/MinGW/bin/gcc.exe
-- Check for working C compiler: C:/MinGW/bin/gcc.exe -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: C:/MinGW/bin/g++.exe
-- Check for working CXX compiler: C:/MinGW/bin/g++.exe -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found PythonInterp: C:/Users/sangjin/AppData/Local/Programs/Python/Python37-32/python.exe (found version "3.7.4")
-- Configuring done
-- Generating done
-- Build files have been written to: C:/googletest-master/build
但是当我运行 mingw32-make 时,我收到以下错误消息。
C:\googletest-master\build>mingw32-make
Scanning dependencies of target gtest
[ 12%] Building CXX object googletest/CMakeFiles/gtest.dir/src/gtest-all.cc.obj
In file included from C:\googletest-master\googletest\src\gtest-all.cc:41:
C:/googletest-master/googletest/src/gtest.cc:86:11: fatal error: crtdbg.h: No such file or directory
# include <crtdbg.h> // NOLINT
^~~~~~~~~~
compilation terminated.
googletest\CMakeFiles\gtest.dir\build.make:62: recipe for target 'googletest/CMakeFiles/gtest.dir/src/gtest-all.cc.obj' failed
mingw32-make[2]: *** [googletest/CMakeFiles/gtest.dir/src/gtest-all.cc.obj] Error 1
CMakeFiles\Makefile2:171: recipe for target 'googletest/CMakeFiles/gtest.dir/all' failed
mingw32-make[1]: *** [googletest/CMakeFiles/gtest.dir/all] Error 2
Makefile:139: recipe for target 'all' failed
mingw32-make: *** [all] Error 2
C:\googletest-master\build>
谁能帮我解决这个问题。
【问题讨论】:
-
crtdbg.h是一个 Visual Studio 文件(请参阅here)。您是否在使用 mingw 构建之前清理了 CMake 缓存,或者为 mingw 构建使用了不同的 CMake 构建文件夹?另外,请复制/粘贴实际输出,而不是在 Stackoverflow 上使用图片/图像。 -
我意识到了这一点,并尝试通过使用链接编辑 gtest.cc 来解决 crtdbg.h 问题,但其他与 Visual Studio 相关的头文件(例如 debugapi.h)仍然导致问题。
-
是的,
gtest.cc文件包含crtdbg.h标头,您可以编辑该文件以尝试解决该问题。但该标题可能包含在内是有原因的。运行 mingw 的机器上是否安装了 Visual Studio? -
没有。我还没有在我的机器上安装 Visual Studio。
-
根据
gtest.c的内容,似乎假设所有Windows 环境都安装了某种形式的Visual Studio C++ 包。
标签: cmake mingw googletest