C++ 配置:错误:C++;编译器无法在macOS上创建可执行文件

C++ 配置:错误:C++;编译器无法在macOS上创建可执行文件,c++,terminal,g++,C++,Terminal,G++,我正在尝试运行iPreeQC部分 我使用的是macOS Catalina版本10.15.7,不幸的是,每次输入/configure时,我都会出现以下错误: [IPHREEQC][1]bob@LIBRLTMCKM0FWJ1W iphreeqc-3.6.2-15100 % ./configure checking for a BSD-compatible install... /usr/bin/install -c checking whether build environment is sane

我正在尝试运行iPreeQC部分

我使用的是macOS Catalina版本
10.15.7
,不幸的是,每次输入
/configure
时,我都会出现以下错误:

[IPHREEQC][1]bob@LIBRLTMCKM0FWJ1W iphreeqc-3.6.2-15100 % ./configure
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... config/install-sh -c -d
checking for gawk... no
checking for mawk... no
checking for nawk... no
checking for awk... awk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking whether make supports nested variables... (cached) yes
checking for g++... g++
checking whether the C++ compiler works... no
configure: error: in `/Users/bob/Desktop/Work/iphreeqc-3.6.2-15100':
configure: error: C++ compiler cannot create executables
See `config.log' for more details
配置日志部分显示

*This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.

It was created by IPhreeqc configure 3.6.2-15100, which was
generated by GNU Autoconf 2.69.  Invocation command line was

  $ ./configure 

## --------- ##
## Platform. ##
## --------- ##

hostname = LIBRLTMCKM0FWJ1W
uname -m = x86_64
uname -r = 19.6.0
uname -s = Darwin
uname -v = Darwin Kernel Version 19.6.0: Mon Aug 31 22:12:52 PDT 2020; root:xnu-6153.141.2~1/RELEASE_X86_64

/usr/bin/uname -p = i386
/bin/uname -X     = unknown

/bin/arch              = unknown
/usr/bin/arch -k       = unknown
/usr/convex/getsysinfo = unknown
/usr/bin/hostinfo      = Mach kernel version:
     Darwin Kernel Version 19.6.0: Mon Aug 31 22:12:52 PDT 2020; root:xnu-6153.141.2~1/RELEASE_X86_64
Kernel configured for up to 4 processors.
2 processors are physically available.
4 processors are logically available.
Processor type: x86_64h (Intel x86-64h Haswell)
Processors active: 0 1 2 3
Primary memory available: 8.00 gigabytes
Default processor set: 365 tasks, 1435 threads, 4 processors
Load average: 3.31, Mach factor: 1.55
/bin/machine           = unknown
/usr/bin/oslevel       = unknown
/bin/universe          = unknown

PATH: /usr/local/bin
PATH: /usr/bin
PATH: /bin
PATH: /usr/sbin
PATH: /sbin
PATH: /opt/X11/bin
PATH: /Library/Apple/usr/bin


## ----------- ##
## Core tests. ##
## ----------- ##

configure:2581: checking for a BSD-compatible install
configure:2649: result: /usr/bin/install -c
configure:2660: checking whether build environment is sane
configure:2715: result: yes
configure:2866: checking for a thread-safe mkdir -p
configure:2905: result: config/install-sh -c -d
configure:2912: checking for gawk
configure:2942: result: no
configure:2912: checking for mawk
configure:2942: result: no
configure:2912: checking for nawk
configure:2942: result: no
configure:2912: checking for awk
configure:2928: found /usr/bin/awk
configure:2939: result: awk
configure:2950: checking whether make sets $(MAKE)
configure:2972: result: yes
configure:3001: checking whether make supports nested variables
configure:3018: result: yes
configure:3158: checking whether make supports nested variables
configure:3175: result: yes
configure:3253: checking for g++
configure:3269: found /usr/local/bin/g++
configure:3280: result: g++
configure:3307: checking for C++ compiler version
configure:3316: g++ --version >&5
g++ (GCC) 9.2.0
Copyright (C) 2019 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.

configure:3327: $? = 0
configure:3316: g++ -v >&5
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/usr/local/libexec/gcc/x86_64-apple-darwin19/9.2.0/lto-wrapper
Target: x86_64-apple-darwin19
Configured with: ../gcc-9.2.0/configure --build=x86_64-apple-darwin19 --disable-nls --enable-checking=release --with-system-zlib --disable-multilib --with-sysroot=/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk --enable-languages=c,c++,fortran --with-gmp=/usr/local --with-mpc=/usr/local --with-mpfr=/usr/local
Thread model: posix
gcc version 9.2.0 (GCC) 
configure:3327: $? = 0
configure:3316: g++ -V >&5
g++: error: unrecognized command line option '-V'
g++: fatal error: no input files
compilation terminated.
configure:3327: $? = 1
configure:3316: g++ -qversion >&5
g++: error: unrecognized command line option '-qversion'; did you mean '--version'?
g++: fatal error: no input files
compilation terminated.
configure:3327: $? = 1
configure:3347: checking whether the C++ compiler works
configure:3369: g++    conftest.cpp  >&5
ld: library not found for -lSystem
collect2: error: ld returned 1 exit status
configure:3373: $? = 1
configure:3411: result: no
configure: failed program was:
| /* confdefs.h */
| #define PACKAGE_NAME "IPhreeqc"
| #define PACKAGE_TARNAME "iphreeqc"
| #define PACKAGE_VERSION "3.6.2-15100"
| #define PACKAGE_STRING "IPhreeqc 3.6.2-15100"
| #define PACKAGE_BUGREPORT "charlton@usgs.gov"
| #define PACKAGE_URL ""
| #define PACKAGE "iphreeqc"
| #define VERSION "3.6.2-15100"
| #define SWIG_SHARED_OBJ 1
| #define USE_PHRQ_ALLOC 1
| #define NDEBUG 1
| /* end confdefs.h.  */
| 
| int
| main ()
| {
| 
|   ;
|   return 0;
| }
configure:3416: error: in `/Users/bob/Desktop/Work/iphreeqc-3.6.2-15100':
configure:3418: 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=
ac_cv_env_CFLAGS_value=
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=
ac_cv_env_CXXFLAGS_value=
ac_cv_env_CXX_set=
ac_cv_env_CXX_value=
ac_cv_env_FCFLAGS_set=
ac_cv_env_FCFLAGS_value=
ac_cv_env_FC_set=
ac_cv_env_FC_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_prog_AWK=awk
ac_cv_prog_ac_ct_CXX=g++
ac_cv_prog_make_make_set=yes
am_cv_make_support_nested_variables=yes

## ----------------- ##
## Output variables. ##
## ----------------- ##

ACLOCAL='${SHELL} /Users/bob/Desktop/Work/iphreeqc-3.6.2-15100/config/missing aclocal-1.15'
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} /Users/bob/Desktop/Work/iphreeqc-3.6.2-15100/config/missing autoconf'
AUTOHEADER='${SHELL} /Users/bob/Desktop/Work/iphreeqc-3.6.2-15100/config/missing autoheader'
AUTOMAKE='${SHELL} /Users/bob/Desktop/Work/iphreeqc-3.6.2-15100/config/missing automake-1.15'
AWK='awk'
BUILD_FORTRAN_FALSE=''
BUILD_FORTRAN_TRUE=''
CC=''
CCDEPMODE=''
CFLAGS=''
CPP=''
CPPFLAGS=''
CXX='g++'
CXXCPP=''
CXXDEPMODE=''
CXXFLAGS=''
CYGPATH_W='echo'
DEFS=''
DEPDIR=''
DLLTOOL=''
DSYMUTIL=''
DUMPBIN=''
ECHO_C='\c'
ECHO_N=''
ECHO_T=''
EGREP=''
EXEEXT=''
F77=''
FC=''
FCFLAGS=''
FCLIBS=''
FC_MODEXT=''
FFLAGS=''
FGREP=''
FORTRAN_MODULE_FALSE=''
FORTRAN_MODULE_TRUE=''
GREP=''
INSTALL_DATA='${INSTALL} -m 644'
INSTALL_PROGRAM='${INSTALL}'
INSTALL_SCRIPT='${INSTALL}'
INSTALL_STRIP_PROGRAM='$(install_sh) -c -s'
LD=''
LDFLAGS=''
LIBOBJS=''
LIBS=''
LIBTOOL=''
LIPO=''
LN_S=''
LTLIBOBJS=''
LT_SYS_LIBRARY_PATH=''
MAKEINFO='${SHELL} /Users/bob/Desktop/Work/iphreeqc-3.6.2-15100/config/missing makeinfo'
MANIFEST_TOOL=''
MKDIR_P='config/install-sh -c -d'
NM=''
NMEDIT=''
OBJDUMP=''
OBJEXT=''
OTOOL64=''
OTOOL=''
PACKAGE='iphreeqc'
PACKAGE_BUGREPORT='charlton@usgs.gov'
PACKAGE_NAME='IPhreeqc'
PACKAGE_STRING='IPhreeqc 3.6.2-15100'
PACKAGE_TARNAME='iphreeqc'
PACKAGE_URL=''
PACKAGE_VERSION='3.6.2-15100'
PATH_SEPARATOR=':'
POW_LIB=''
RANLIB=''
SED=''
SET_MAKE=''
SHELL='/bin/sh'
STRIP=''
VERSION='3.6.2-15100'
ac_ct_AR=''
ac_ct_CC=''
ac_ct_CXX='g++'
ac_ct_DUMPBIN=''
ac_ct_FC=''
am__EXEEXT_FALSE=''
am__EXEEXT_TRUE=''
am__fastdepCC_FALSE=''
am__fastdepCC_TRUE=''
am__fastdepCXX_FALSE=''
am__fastdepCXX_TRUE=''
am__include=''
am__isrc=''
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} /Users/bob/Desktop/Work/iphreeqc-3.6.2-15100/config/install-sh'
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 "IPhreeqc"
#define PACKAGE_TARNAME "iphreeqc"
#define PACKAGE_VERSION "3.6.2-15100"
#define PACKAGE_STRING "IPhreeqc 3.6.2-15100"
#define PACKAGE_BUGREPORT "charlton@usgs.gov"
#define PACKAGE_URL ""
#define PACKAGE "iphreeqc"
#define VERSION "3.6.2-15100"
#define SWIG_SHARED_OBJ 1
#define USE_PHRQ_ALLOC 1
#define NDEBUG 1

configure: exit 77

如何修复此错误?

问题源于./configure脚本对使用哪个g++感到困惑:从Sourceforge下载并安装在/usr/local/bin中的GNU g++和位于/usr/bin中的Apple XCode g++。在我的例子中,诀窍是通过执行以下操作临时从$PATH变量中删除/usr/local/bin:

echo$PATH

要查看其中的内容(/usr/local/bin、/usr/bin和许多其他文件夹),请

export PATH=/usr/bin:[与echo命令输出中的其他文件夹相同,但/usr/local/bin除外]

并运行./configure。这基本上告诉./configure脚本忽略安装Sourceforge GNU g++的文件夹/usr/local/bin,只使用位于/usr/bin中的苹果XCode g++


我通过详细查看config.log找到了答案。不管我是把SooSeFig或Apple G++链接到“G++”命令(通过别名G+++ =…),./Script脚本默认是SooCurfG+++找到的,并试图在它上面运行苹果命令,我想这就是为什么脚本说C++编译器不工作的原因。通过忽略/usr/local/bin,它在默认情况下找到了Apple g++。

是否检查了config.log以获取实际的错误消息?config.log发布在上面。我找不到错误
ld:library not found for-lSystem
可能是罪魁祸首。似乎表明您可能没有正确设置编译器工具链或SDK。那么告诉我们,您是如何安装clang和/或Xcode命令行工具的?