gpt4 book ai didi

c++ - C++ 编译器 g++.exe 无法编译简单的测试程序 - 确定 CXX 编译器是否工作失败

转载 作者:行者123 更新时间:2023-11-30 05:11:18 25 4
gpt4 key购买 nike

我一直在尝试将适用于 C++ 的 AWS 开发工具包集成到我的 Netbeans 项目中。我尝试使用 cmake 命令,但失败并出现以下错误。

这是在命令提示符下运行命令的文本

    C:\Users\jense\Desktop\code libraries\aws-sdk-cpp-master\aws-sdk-cpp-master>"C:\Users\jense\Desktop\code libraries\cmake-3.8.2-win64-x64\cmake-3.8.2-win64-x64\bin\cmake" .
-- Could NOT find Git (missing: GIT_EXECUTABLE)
-- TARGET_ARCH not specified; inferring host OS to be platform compilation target
-- Building AWS libraries as shared objects
-- Generating windows build config
-- Building project version: 1.1.10
-- The CXX compiler identification is GNU 5.3.0
-- Check for working CXX compiler: C:/MinGW/bin/g++.exe
CMake Error: Generator: execution of make failed. Make command was: "nmake" "/NOLOGO" "cmTC_ade23\fast"
-- Check for working CXX compiler: C:/MinGW/bin/g++.exe -- broken
CMake Error at C:/Users/jense/Desktop/code libraries/cmake-3.8.2-win64-x64/cmake-3.8.2-win64-x64/share/cmake-3.8/Modules/CMakeTestCXXCompiler.cmake:44 (message):
The C++ compiler "C:/MinGW/bin/g++.exe" is not able to compile a simple
test program.

It fails with the following output:

Change Dir: C:/Users/jense/Desktop/code libraries/aws-sdk-cpp-master/aws-sdk-cpp-master/CMakeFiles/CMakeTmp

Run Build Command:"nmake" "/NOLOGO" "cmTC_ade23\fast"

Generator: execution of make failed. Make command was: "nmake" "/NOLOGO"
"cmTC_ade23\fast"

CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
CMakeLists.txt:105 (project)


-- Configuring incomplete, errors occurred!
See also "C:/Users/jense/Desktop/code libraries/aws-sdk-cpp-master/aws-sdk-cpp-master/CMakeFiles/CMakeOutput.log".
See also "C:/Users/jense/Desktop/code libraries/aws-sdk-cpp-master/aws-sdk-cpp-master/CMakeFiles/CMakeError.log".

这是我的 CMakeError.txt

    Determining if the CXX compiler works failed with the following output:
Change Dir: C:/Users/jense/Desktop/code libraries/aws-sdk-cpp-master/aws-sdk-cpp-master/CMakeFiles/CMakeTmp

Run Build Command:"nmake" "/NOLOGO" "cmTC_a5997\fast"

Generator: execution of make failed. Make command was: "nmake" "/NOLOGO" "cmTC_a5997\fast"

在我的 CMakeOutput.txt

The CXX compiler identification is GNU, found in "C:/Users/jense/Desktop/code libraries/aws-sdk-cpp-master/aws-sdk-cpp-master/CMakeFiles/3.8.2/CompilerIdCXX/a.exe"

Compiling the CXX compiler identification source file "CMakeCXXCompilerId.cpp" succeeded.
Compiler: C:/MinGW/bin/g++.exe
Build flags:
Id flags:

The output was:
0
Compilation of the CXX compiler identification source "CMakeCXXCompilerId.cpp" produced "a.exe"

它说 g++ 不能编译一个简单的测试程序,但是它似乎在我的其他 c++ 程序上运行良好。此外,它指示我运行 nmake /NOLOGO cmTC_a5997\fast。我在我的计算机上找不到安装的 nmake,这是问题所在吗?或者这只是一系列错误中发生的另一个错误?

我该如何解决这个问题?

我使用的是 Netbeans 8.2 而不是 Visual Studio。

我在 SO 上看到的所有答案似乎都与我的问题无关,它们是与 visual studio 相关的答案和/或解决我没有的问题的东西。

谢谢!

最佳答案

NMake 是 Microsoft 工具链中的传统 make 程序。由于您使用 MinGW,因此您需要 mingw32-make,但 CMake 默认为 Windows 上的 MS 工具链生成器。使用 -G "MinGW Makefiles" 调用 CMake 以切换到 MinGW 生成器。

-G "Unix Makefiles",就像 Miles Budnek 在问题评论中建议的那样,是类 Unix 目标的默认生成器。例如,它是 Linux 上的默认值。但是,它与 MinGW 相同,不会在您的情况下工作。

附言1:尤其是在 Windows 上,make 在使用所有 CPU 核心方面存在问题。您可能想看看 Ninja .它通常是 make 的直接替代品,可以使用 CMake 的 -G Ninja 激活,并且可以更好地处理并行构建。

附言2(与问题无关):避免在目录路径中的任何位置使用空格。这些是麻烦的主要来源,因为您必须在任何地方正确地引用这些路径。这是 (a) 出奇地难以正确,(b) 一些你很容易完全忘记的事情,以及 (c) 一些你所有的第 3 方依赖项的构建系统也需要具备的能力。不使用空格是避免所有这些潜在陷阱的最简单方法。

关于c++ - C++ 编译器 g++.exe 无法编译简单的测试程序 - 确定 CXX 编译器是否工作失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45124655/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com