g++ cannot be found

g++ cannot be found

本文关键字:found be cannot g++      更新时间:2023-10-16

我写了一个c++程序,如下所示,

#include <iostream>
using namespace std;
main()
{
int a,b,c;
cout<<"Enter two numbers"<<endl;
cin>>a>>b;
c=a+b;
cout<<"Sum of two numbers are"<<c;
}

并尝试使用以下方法编译程序,

home$ g++ add.cpp

我收到此错误,

程序 g++ 可以在以下软件包中找到,g++,奔腾生成器

有人可以帮助我吗?

您需要

安装 g++ 。正如它所建议的那样,它可以在g++包中找到,您可以使用 apt-get .像这样:

sudo apt-get install g++

但是,您可能想要安装 build-essential ,这基本上为您提供了许多有用的构建工具:

sudo apt-get install build-essential

在 Ubuntu 的发行版中,默认情况下不安装 g++。要安装它,您应该安装"build-essentials"软件包。您可以使用 GUI 包管理器找到此包,或打开终端并编写:

sudo apt-get install build-essentials

Build-essentials包含许多用于编译,执行和调试本机程序的工具。