我目前正在尝试使用 Anjuta 来熟悉 C++。我尝试Hello World
在 -file 中运行一个简单的程序main.cc
:
#include <iostream>
int main()
{
std::cout << "Hello world!" << std::endl;
return 0;
}
但它没有成功完成,我收到了以下内容config.log
:
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
It was created by foobar_cpp configure 0.1, which was
generated by GNU Autoconf 2.69. Invocation command line was
$ /home/user/foobar-cpp/configure --enable-maintainer-mode CFLAGS=-g -O0 CXXFLAGS=-g -O0 JFLAGS=-g -O0 FFLAGS=-g -O0
## --------- ##
## Platform. ##
## --------- ##
hostname = user-thinkpad
uname -m = x86_64
uname -r = 5.8.0-53-generic
uname -s = Linux
uname -v = #60~20.04.1-Ubuntu SMP Thu May 6 09:52:46 UTC 2021
/usr/bin/uname -p = x86_64
/bin/uname -X = unknown
/bin/arch = x86_64
/usr/bin/arch -k = unknown
/usr/convex/getsysinfo = unknown
/usr/bin/hostinfo = unknown
/bin/machine = unknown
/usr/bin/oslevel = unknown
/bin/universe = unknown
PATH: /usr/local/sbin
PATH: /usr/local/bin
PATH: /usr/sbin
PATH: /usr/bin
PATH: /sbin
PATH: /bin
PATH: /usr/games
PATH: /usr/local/games
PATH: /snap/bin
## ----------- ##
## Core tests. ##
## ----------- ##
configure:2448: checking for a BSD-compatible install
configure:2516: result: /usr/bin/install -c
configure:2527: checking whether build environment is sane
configure:2582: result: yes
configure:2731: checking for a thread-safe mkdir -p
configure:2770: result: /usr/bin/mkdir -p
configure:2777: checking for gawk
configure:2807: result: no
configure:2777: checking for mawk
configure:2793: found /usr/bin/mawk
configure:2804: result: mawk
configure:2815: checking whether make sets $(MAKE)
configure:2837: result: yes
configure:2866: checking whether make supports nested variables
configure:2883: result: yes
configure:3021: checking whether make supports nested variables
configure:3038: result: yes
configure:3108: checking for g++
configure:3138: result: no
configure:3108: checking for c++
configure:3138: result: no
configure:3108: checking for gpp
configure:3138: result: no
configure:3108: checking for aCC
configure:3138: result: no
configure:3108: checking for CC
configure:3138: result: no
configure:3108: checking for cxx
configure:3138: result: no
configure:3108: checking for cc++
configure:3138: result: no
configure:3108: checking for cl.exe
configure:3138: result: no
configure:3108: checking for FCC
configure:3138: result: no
configure:3108: checking for KCC
configure:3138: result: no
configure:3108: checking for RCC
configure:3138: result: no
configure:3108: checking for xlC_r
configure:3138: result: no
configure:3108: checking for xlC
configure:3138: result: no
configure:3162: checking for C++ compiler version
configure:3171: g++ --version >&5
/home/user/foobar-cpp/configure: line 3173: g++: command not found
configure:3182: $? = 127
configure:3171: g++ -v >&5
/home/user/foobar-cpp/configure: line 3173: g++: command not found
configure:3182: $? = 127
configure:3171: g++ -V >&5
/home/user/foobar-cpp/configure: line 3173: g++: command not found
configure:3182: $? = 127
configure:3171: g++ -qversion >&5
/home/user/foobar-cpp/configure: line 3173: g++: command not found
configure:3182: $? = 127
configure:3202: checking whether the C++ compiler works
configure:3224: g++ -g -O0 conftest.cpp >&5
/home/user/foobar-cpp/configure: line 3226: g++: command not found
configure:3228: $? = 127
configure:3266: result: no
configure: failed program was:
| /* confdefs.h */
| #define PACKAGE_NAME "foobar_cpp"
| #define PACKAGE_TARNAME "foobar_cpp"
| #define PACKAGE_VERSION "0.1"
| #define PACKAGE_STRING "foobar_cpp 0.1"
| #define PACKAGE_BUGREPORT ""
| #define PACKAGE_URL ""
| #define PACKAGE "foobar_cpp"
| #define VERSION "0.1"
| /* end confdefs.h. */
|
| int
| main ()
| {
|
| ;
| return 0;
| }
configure:3271: error: in `/home/user/foobar-cpp/Debug':
configure:3273: error: C++ compiler cannot create executables
See `config.log' for more details
## ---------------- ##
## Cache variables. ##
## ---------------- ##
ac_cv_env_CCC_set=
ac_cv_env_CCC_value=
ac_cv_env_CC_set=
ac_cv_env_CC_value=
ac_cv_env_CFLAGS_set=set
ac_cv_env_CFLAGS_value='-g -O0'
ac_cv_env_CPPFLAGS_set=
ac_cv_env_CPPFLAGS_value=
ac_cv_env_CPP_set=
ac_cv_env_CPP_value=
ac_cv_env_CXXCPP_set=
ac_cv_env_CXXCPP_value=
ac_cv_env_CXXFLAGS_set=set
ac_cv_env_CXXFLAGS_value='-g -O0'
ac_cv_env_CXX_set=
ac_cv_env_CXX_value=
ac_cv_env_LDFLAGS_set=
ac_cv_env_LDFLAGS_value=
ac_cv_env_LIBS_set=
ac_cv_env_LIBS_value=
ac_cv_env_LT_SYS_LIBRARY_PATH_set=
ac_cv_env_LT_SYS_LIBRARY_PATH_value=
ac_cv_env_build_alias_set=
ac_cv_env_build_alias_value=
ac_cv_env_host_alias_set=
ac_cv_env_host_alias_value=
ac_cv_env_target_alias_set=
ac_cv_env_target_alias_value=
ac_cv_path_install='/usr/bin/install -c'
ac_cv_path_mkdir=/usr/bin/mkdir
ac_cv_prog_AWK=mawk
ac_cv_prog_make_make_set=yes
am_cv_make_support_nested_variables=yes
## ----------------- ##
## Output variables. ##
## ----------------- ##
ACLOCAL='${SHELL} /home/user/foobar-cpp/missing aclocal-1.16'
ALL_LINGUAS=''
AMDEPBACKSLASH=''
AMDEP_FALSE=''
AMDEP_TRUE=''
AMTAR='$${TAR-tar}'
AM_BACKSLASH='\'
AM_DEFAULT_V='$(AM_DEFAULT_VERBOSITY)'
AM_DEFAULT_VERBOSITY='0'
AM_V='$(V)'
AR=''
AUTOCONF='${SHELL} /home/user/foobar-cpp/missing autoconf'
AUTOHEADER='${SHELL} /home/user/foobar-cpp/missing autoheader'
AUTOMAKE='${SHELL} /home/user/foobar-cpp/missing automake-1.16'
AWK='mawk'
CATALOGS=''
CATOBJEXT=''
CC=''
CCDEPMODE=''
CFLAGS='-g -O0'
CPP=''
CPPFLAGS=''
CXX='g++'
CXXCPP=''
CXXDEPMODE=''
CXXFLAGS='-g -O0'
CYGPATH_W='echo'
DATADIRNAME=''
DEFS=''
DEPDIR=''
DLLTOOL=''
DSYMUTIL=''
DUMPBIN=''
ECHO_C=''
ECHO_N='-n'
ECHO_T=''
EGREP=''
EXEEXT=''
FGREP=''
GETTEXT_PACKAGE=''
GMOFILES=''
GMSGFMT=''
GREP=''
INSTALL_DATA='${INSTALL} -m 644'
INSTALL_PROGRAM='${INSTALL}'
INSTALL_SCRIPT='${INSTALL}'
INSTALL_STRIP_PROGRAM='$(install_sh) -c -s'
INSTOBJEXT=''
INTLLIBS=''
INTLTOOL_CAVES_RULE=''
INTLTOOL_DESKTOP_RULE=''
INTLTOOL_DIRECTORY_RULE=''
INTLTOOL_EXTRACT=''
INTLTOOL_KBD_RULE=''
INTLTOOL_KEYS_RULE=''
INTLTOOL_MERGE=''
INTLTOOL_OAF_RULE=''
INTLTOOL_PERL=''
INTLTOOL_POLICY_RULE=''
INTLTOOL_PONG_RULE=''
INTLTOOL_PROP_RULE=''
INTLTOOL_SCHEMAS_RULE=''
INTLTOOL_SERVER_RULE=''
INTLTOOL_SERVICE_RULE=''
INTLTOOL_SHEET_RULE=''
INTLTOOL_SOUNDLIST_RULE=''
INTLTOOL_THEME_RULE=''
INTLTOOL_UI_RULE=''
INTLTOOL_UPDATE=''
INTLTOOL_V_MERGE=''
INTLTOOL_V_MERGE_OPTIONS=''
INTLTOOL_XAM_RULE=''
INTLTOOL_XML_NOMERGE_RULE=''
INTLTOOL_XML_RULE=''
INTLTOOL__v_MERGE_0=''
INTLTOOL__v_MERGE_=''
INTL_MACOSX_LIBS=''
LD=''
LDFLAGS=''
LIBOBJS=''
LIBS=''
LIBTOOL=''
LIPO=''
LN_S=''
LTLIBOBJS=''
LT_SYS_LIBRARY_PATH=''
MAKEINFO='${SHELL} /home/user/foobar-cpp/missing makeinfo'
MANIFEST_TOOL=''
MKDIR_P='/usr/bin/mkdir -p'
MKINSTALLDIRS=''
MSGFMT=''
MSGFMT_OPTS=''
MSGMERGE=''
NM=''
NMEDIT=''
OBJDUMP=''
OBJEXT=''
OTOOL64=''
OTOOL=''
PACKAGE='foobar_cpp'
PACKAGE_BUGREPORT=''
PACKAGE_NAME='foobar_cpp'
PACKAGE_STRING='foobar_cpp 0.1'
PACKAGE_TARNAME='foobar_cpp'
PACKAGE_URL=''
PACKAGE_VERSION='0.1'
PATH_SEPARATOR=':'
POFILES=''
POSUB=''
PO_IN_DATADIR_FALSE=''
PO_IN_DATADIR_TRUE=''
RANLIB=''
SED=''
SET_MAKE=''
SHELL='/bin/bash'
STRIP=''
USE_NLS=''
VERSION='0.1'
XGETTEXT=''
ac_ct_AR=''
ac_ct_CC=''
ac_ct_CXX=''
ac_ct_DUMPBIN=''
am__EXEEXT_FALSE=''
am__EXEEXT_TRUE=''
am__fastdepCC_FALSE=''
am__fastdepCC_TRUE=''
am__fastdepCXX_FALSE=''
am__fastdepCXX_TRUE=''
am__include=''
am__isrc=' -I$(srcdir)'
am__leading_dot='.'
am__nodep=''
am__quote=''
am__tar='$${TAR-tar} chof - "$$tardir"'
am__untar='$${TAR-tar} xf -'
bindir='${exec_prefix}/bin'
build=''
build_alias=''
build_cpu=''
build_os=''
build_vendor=''
datadir='${datarootdir}'
datarootdir='${prefix}/share'
docdir='${datarootdir}/doc/${PACKAGE_TARNAME}'
dvidir='${docdir}'
exec_prefix='NONE'
host=''
host_alias=''
host_cpu=''
host_os=''
host_vendor=''
htmldir='${docdir}'
includedir='${prefix}/include'
infodir='${datarootdir}/info'
install_sh='${SHELL} /home/user/foobar-cpp/install-sh'
intltool__v_merge_options_0=''
intltool__v_merge_options_=''
libdir='${exec_prefix}/lib'
libexecdir='${exec_prefix}/libexec'
localedir='${datarootdir}/locale'
localstatedir='${prefix}/var'
mandir='${datarootdir}/man'
mkdir_p='$(MKDIR_P)'
oldincludedir='/usr/include'
pdfdir='${docdir}'
prefix='NONE'
program_transform_name='s,x,x,'
psdir='${docdir}'
runstatedir='${localstatedir}/run'
sbindir='${exec_prefix}/sbin'
sharedstatedir='${prefix}/com'
sysconfdir='${prefix}/etc'
target_alias=''
## ----------- ##
## confdefs.h. ##
## ----------- ##
/* confdefs.h */
#define PACKAGE_NAME "foobar_cpp"
#define PACKAGE_TARNAME "foobar_cpp"
#define PACKAGE_VERSION "0.1"
#define PACKAGE_STRING "foobar_cpp 0.1"
#define PACKAGE_BUGREPORT ""
#define PACKAGE_URL ""
#define PACKAGE "foobar_cpp"
#define VERSION "0.1"
configure: exit 77
答案1
解决方法是安装g++
。
sudo apt install g++
这是必要的,因为 IDE 仅仅提供了查看代码的界面,最后它运行一个 C++ 编译器来编译程序。