简体   繁体   English

在 Windows 10 上使用 mingw 的 CMake:检测 CXX 编译器 ABI 信息 - 失败

[英]CMake with mingw on Windows 10: Detecting CXX compiler ABI info - failed

I want to use cmake to create MinGW Makefiles on windows 10. I have installed mingw and I can use mingw32-make and g++ commands without issue.我想使用 cmake 在 Windows 10 上创建 MinGW Makefile。我已经安装了 mingw,我可以毫无问题地使用 mingw32-make 和 g++ 命令。

The test project is a super simple CMakeLists.txt file:测试项目是一个超级简单的 CMakeLists.txt 文件:

cmake_minimum_required(VERSION 3.10)
project(hello-world)
add_executable(hello-world main.cpp)

and a simple main.cpp file:和一个简单的 main.cpp 文件:

#include <iostream>
int main() {
    std::cout << "hello Visual Studio Code! :)" << '\n'; 
    return 0;
}

These are the commands I use to create the makefiles:这些是我用来创建 makefile 的命令:

>> mkdir build
>> cd build
>> cmake -G "MinGW Makefiles" ..

This is where I get errors:这是我收到错误的地方:

CMake Error at C:/Program Files (x86)/CMake/share/cmake-3.10/Modules/CMakeDetermineCompilerId.cmake:495 (file):
file STRINGS file
"C:/Projects/test/build/CMakeFiles/3.10.1/CompilerIdCXX/a.exe" cannot be read.

... some more errors in the test files

-- The CXX compiler identification is GNU 6.3.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 - failed
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring incomplete, errors occurred!

This is from the error log:这是来自错误日志:

The CXX compiler identification could not be found in "C:/Projects/test/build/CMakeFiles/3.10.1/CompilerIdCXX/a.exe"

What is the CXX compiler ABI info and how can it be, that there is a working CXX compiler detected but this fails?什么是 CXX 编译器 ABI 信息,怎么可能检测到正在运行的 CXX 编译器但失败了?

Let me know if you need anymore info about the setup!如果您需要有关设置的更多信息,请告诉我!

What turned out to be my culprit was Windows Defender!原来是我的罪魁祸首是 Windows Defender! Turned that off and the CXX compiler ABI info - failed issue went away.关闭它,CXX 编译器 ABI 信息 - 失败的问题就消失了。

I used the CMake-GUI tool to figure out the missing tool dependencies.我使用 CMake-GUI 工具找出缺少的工具依赖项。 For example : CMAKE_ADDR2LINE was not set, once I pointed it to the correct location of addr2line.exe ,the errors were resolved.例如:CMAKE_ADDR2LINE 没有设置,一旦我将它指向 addr2line.exe 的正确位置,错误就解决了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM