首页 > 解决方案 > g++.exe: 安装问题, cannot exec `as': No such file or directory

问题描述

我正在尝试学习 C++,我使用 Cygwin 在 Windows 上下载并安装了 g++,遵循本教程: https ://www.cs.odu.edu/~zeil/cs250PreTest/latest/Public/installingACompiler/#installing-the- mingw 编译器

就像在教程中一样,最后,我检查了 g++ 是否已安装:

PS D:\Desktop\coursera_ODS_in_c-\Week 2> g++ --version
g++.exe (GCC) 3.4.5 (mingw-vista special r3)
Copyright (C) 2004 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

然后我尝试运行这段代码:

#include <iostream>

int main() {
    int num = 7;
    
    std::cout << "Values:" << num << std::endl;
    std::cout << "Address: " << &num << std::endl;
    return 0;
}

通过使用这个

PS D:\Desktop\coursera_ODS_in_c-\Week 2> g++ main.cpp

但我明白了:

g++.exe: installation problem, cannot exec `as': No such file or directory

你如何解决这个问题?

标签: c++g++

解决方案


消息:

g++.exe: installation problem

明确指出您的 G++ 编译器的安装有问题。另外,3.4.5 版本太旧了。当前的稳定版本是 10.2(2020 年 7 月 23 日发布),用最新版本重新安装它可能会解决您的问题。(由于没有给出足够的细节,错误原因仍然是个谜。)

尝试下载最新版本的 GNU GCC 编译器:GNU GCC

OTOH,程序编码正确,OnlineGDB上没有报告错误。


推荐阅读