我正在尝试调用./configure
命令。但是,它显示此错误:
C compiler cannot create executables.
这里是输出:
checking for a BSD-compatible install... /home/linuxbrew/.linuxbrew/bin/ginstall -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /home/linuxbrew/.linuxbrew/bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking whether to enable maintainer-specific portions of Makefiles... no
checking for gcc... gcc
checking whether the C compiler works... no
configure: error: C compiler cannot create executables
See `config.log' for more details
我检查了config.log
,它可以检测到gcc
已安装但找不到conftest.c
文件。我已经尝试过:
sudo apt-get update
sudo apt-get install build-essential
但仍然显示错误。我还检查了我的libc6
已经安装了最新版本。
如何解决?
这是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 libpng configure 1.6.32, which was
generated by GNU Autoconf 2.69. Invocation command line was
$ ./configure
## --------- ##
## Platform. ##
## --------- ##
hostname = MP3C-ISIT-048
uname -m = x86_64
uname -r = 4.4.0-116-generic
uname -s = Linux
uname -v = #140-Ubuntu SMP Mon Feb 12 21:23:04 UTC 2018
/usr/bin/uname -p = unknown
/bin/uname -X = unknown
/bin/arch = unknown
/usr/bin/arch -k = unknown
/usr/convex/getsysinfo = unknown
/usr/bin/hostinfo = unknown
/bin/machine = unknown
/usr/bin/oslevel = unknown
/bin/universe = unknown
PATH: /home/shrinivasan/anaconda2/bin
PATH: /usr/local/MATLAB/R2016b/bin/matlab
PATH: /usr/local/cuda/bin
PATH: /home/linuxbrew/.linuxbrew/bin
PATH: /home/linuxbrew/.linuxbrew/sbin
PATH: /home/shrinivasan/bin
PATH: /home/shrinivasan/.local/bin
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
PATH: /usr/lib
PATH: /usr/local/cuda/bin
## ----------- ##
## Core tests. ##
## ----------- ##
configure:2358: checking for a BSD-compatible install
configure:2426: result: /home/linuxbrew/.linuxbrew/bin/ginstall -c
configure:2437: checking whether build environment is sane
configure:2492: result: yes
configure:2643: checking for a thread-safe mkdir -p
configure:2682: result: /home/linuxbrew/.linuxbrew/bin/mkdir -p
configure:2689: checking for gawk
configure:2705: found /usr/bin/gawk
configure:2716: result: gawk
configure:2727: checking whether make sets $(MAKE)
configure:2749: result: yes
configure:2778: checking whether make supports nested variables
configure:2795: result: yes
configure:2925: checking whether to enable maintainer-specific portions of Makefiles
configure:2934: result: no
configure:3014: checking for gcc
configure:3030: found /usr/bin/gcc
configure:3041: result: gcc
configure:3270: checking for C compiler version
configure:3280: gcc --version >&5
gcc (Ubuntu 5.4.0-6ubuntu1~16.04.9) 5.4.0 20160609
Copyright (C) 2015 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:3291: $? = 0
configure:3280: gcc -v >&5
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/5/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 5.4.0-6ubuntu1~16.04.9' --with-bugurl=file:///usr/share/doc/gcc-5/README.Bugs --enable-languages=c,ada,c++,java,go,d,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-5 --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-libmpx --enable-plugin --with-system-zlib --disable-browser-plugin --enable-java-awt=gtk --enable-gtk-cairo --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-5-amd64/jre --enable-java-home --with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-5-amd64 --with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-5-amd64 --with-arch-directory=amd64 --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --enable-objc-gc --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 5.4.0 20160609 (Ubuntu 5.4.0-6ubuntu1~16.04.9)
configure:3291: $? = 0
configure:3311: checking whether the C compiler works
configure:3333: gcc conftest.c /media/Data/Libs >&5
/usr/bin/ld: cannot find /media/Data/Libs: File format not recognized
collect2: error: ld returned 1 exit status
configure:3337: $? = 1
configure:3375: result: no
configure: failed program was:
| /* confdefs.h */
| #define PACKAGE_NAME "libpng"
| #define PACKAGE_TARNAME "libpng"
| #define PACKAGE_VERSION "1.6.32"
| #define PACKAGE_STRING "libpng 1.6.32"
| #define PACKAGE_BUGREPORT "[email protected]"
| #define PACKAGE_URL ""
| #define PACKAGE "libpng"
| #define VERSION "1.6.32"
| /* end confdefs.h. */
|
| int
| main ()
| {
|
| ;
| return 0;
| }
configure:3380: error: in `/home/shrinivasan/Documents/anneke/software/libpng-1.6.32':
configure:3382: error: C compiler cannot create executables
See `config.log' for more details
## ---------------- ##
## Cache variables. ##
## ---------------- ##
ac_cv_env_CCASFLAGS_set=
ac_cv_env_CCASFLAGS_value=
ac_cv_env_CCAS_set=
ac_cv_env_CCAS_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_LDFLAGS_set=
ac_cv_env_LDFLAGS_value=
ac_cv_env_LIBS_set=set
ac_cv_env_LIBS_value=/media/Data/Libs
ac_cv_env_LT_SYS_LIBRARY_PATH_set=
ac_cv_env_LT_SYS_LIBRARY_PATH_value=
ac_cv_env_PNG_COPTS_set=
ac_cv_env_PNG_COPTS_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='/home/linuxbrew/.linuxbrew/bin/ginstall -c'
ac_cv_path_mkdir=/home/linuxbrew/.linuxbrew/bin/mkdir
ac_cv_prog_AWK=gawk
ac_cv_prog_ac_ct_CC=gcc
ac_cv_prog_make_make_set=yes
am_cv_make_support_nested_variables=yes
## ----------------- ##
## Output variables. ##
## ----------------- ##
ACLOCAL='${SHELL} /home/shrinivasan/Documents/anneke/software/libpng-1.6.32/missing aclocal-1.15'
AMDEPBACKSLASH=''
AMDEP_FALSE=''
AMDEP_TRUE=''
AMTAR='$${TAR-tar}'
AM_BACKSLASH='\'
AM_DEFAULT_V='$(AM_DEFAULT_VERBOSITY)'
AM_DEFAULT_VERBOSITY='1'
AM_V='$(V)'
AR=''
AS=''
AUTOCONF='${SHELL} /home/shrinivasan/Documents/anneke/software/libpng-1.6.32/missing autoconf'
AUTOHEADER='${SHELL} /home/shrinivasan/Documents/anneke/software/libpng-1.6.32/missing autoheader'
AUTOMAKE='${SHELL} /home/shrinivasan/Documents/anneke/software/libpng-1.6.32/missing automake-1.15'
AWK='gawk'
CC='gcc'
CCAS=''
CCASDEPMODE=''
CCASFLAGS=''
CCDEPMODE=''
CFLAGS=''
CPP=''
CPPFLAGS=''
CYGPATH_W='echo'
DEFS=''
DEPDIR=''
DFNCPP=''
DLLTOOL=''
DO_INSTALL_LIBPNG_CONFIG_FALSE=''
DO_INSTALL_LIBPNG_CONFIG_TRUE=''
DO_INSTALL_LIBPNG_PC_FALSE=''
DO_INSTALL_LIBPNG_PC_TRUE=''
DO_INSTALL_LINKS_FALSE=''
DO_INSTALL_LINKS_TRUE=''
DO_PNG_PREFIX_FALSE=''
DO_PNG_PREFIX_TRUE=''
DSYMUTIL=''
DUMPBIN=''
ECHO_C=''
ECHO_N='-n'
ECHO_T=''
EGREP=''
EXEEXT=''
FGREP=''
GREP=''
HAVE_CLOCK_GETTIME_FALSE=''
HAVE_CLOCK_GETTIME_TRUE=''
HAVE_LD_VERSION_SCRIPT_FALSE=''
HAVE_LD_VERSION_SCRIPT_TRUE=''
HAVE_SOLARIS_LD_FALSE=''
HAVE_SOLARIS_LD_TRUE=''
INSTALL_DATA='${INSTALL} -m 644'
INSTALL_PROGRAM='${INSTALL}'
INSTALL_SCRIPT='${INSTALL}'
INSTALL_STRIP_PROGRAM='$(install_sh) -c -s'
LD=''
LDFLAGS=''
LIBOBJS=''
LIBS='/media/Data/Libs'
LIBTOOL=''
LIPO=''
LN_S=''
LTLIBOBJS=''
LT_SYS_LIBRARY_PATH=''
MAINT='#'
MAINTAINER_MODE_FALSE=''
MAINTAINER_MODE_TRUE='#'
MAKEINFO='${SHELL} /home/shrinivasan/Documents/anneke/software/libpng-1.6.32/missing makeinfo'
MANIFEST_TOOL=''
MKDIR_P='/home/linuxbrew/.linuxbrew/bin/mkdir -p'
NM=''
NMEDIT=''
OBJDUMP=''
OBJEXT=''
OTOOL64=''
OTOOL=''
PACKAGE='libpng'
PACKAGE_BUGREPORT='[email protected]'
PACKAGE_NAME='libpng'
PACKAGE_STRING='libpng 1.6.32'
PACKAGE_TARNAME='libpng'
PACKAGE_URL=''
PACKAGE_VERSION='1.6.32'
PATH_SEPARATOR=':'
PNGLIB_MAJOR='1'
PNGLIB_MINOR='6'
PNGLIB_RELEASE='32'
PNGLIB_VERSION='1.6.32'
PNG_ARM_NEON_FALSE=''
PNG_ARM_NEON_TRUE=''
PNG_COPTS=''
PNG_INTEL_SSE_FALSE=''
PNG_INTEL_SSE_TRUE=''
PNG_MIPS_MSA_FALSE=''
PNG_MIPS_MSA_TRUE=''
PNG_POWERPC_VSX_FALSE=''
PNG_POWERPC_VSX_TRUE=''
PNG_PREFIX=''
POW_LIB=''
RANLIB=''
SED=''
SET_MAKE=''
SHELL='/bin/bash'
STRIP=''
SYMBOL_PREFIX=''
VERSION='1.6.32'
ac_ct_AR=''
ac_ct_CC='gcc'
ac_ct_DUMPBIN=''
am__EXEEXT_FALSE=''
am__EXEEXT_TRUE=''
am__fastdepCCAS_FALSE=''
am__fastdepCCAS_TRUE=''
am__fastdepCC_FALSE=''
am__fastdepCC_TRUE=''
am__include=''
am__isrc=''
am__leading_dot='.'
am__nodep=''
am__quote=''
am__tar='$${TAR-tar} chof - "$$tardir"'
am__untar='$${TAR-tar} xf -'
binconfigs=''
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/shrinivasan/Documents/anneke/software/libpng-1.6.32/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}'
pkgconfigdir=''
prefix='NONE'
program_transform_name='s,x,x,'
psdir='${docdir}'
sbindir='${exec_prefix}/sbin'
sharedstatedir='${prefix}/com'
sysconfdir='${prefix}/etc'
target_alias=''
## ----------- ##
## confdefs.h. ##
## ----------- ##
/* confdefs.h */
#define PACKAGE_NAME "libpng"
#define PACKAGE_TARNAME "libpng"
#define PACKAGE_VERSION "1.6.32"
#define PACKAGE_STRING "libpng 1.6.32"
#define PACKAGE_BUGREPORT "[email protected]"
#define PACKAGE_URL ""
#define PACKAGE "libpng"
#define VERSION "1.6.32"
configure: exit 77
答案1
从 config.log 中我们可以看到,gcc 被调用时带有一个附加参数/media/Data/Libs
,它将该参数解释为应该尝试链接的库文件:
configure:3333: gcc conftest.c /media/Data/Libs >&5
/usr/bin/ld: cannot find /media/Data/Libs: File format not recognized
进一步查看,我们可以看到这是通过 autoconf 从您的环境中获取的ac_cv_env_LIBS_value
:
ac_cv_env_LDFLAGS_set=
ac_cv_env_LDFLAGS_value=
ac_cv_env_LIBS_set=set
ac_cv_env_LIBS_value=/media/Data/Libs
ac_cv_env_LT_SYS_LIBRARY_PATH_set=
ac_cv_env_LT_SYS_LIBRARY_PATH_value=
这表明您已经定义了一个环境变量LIBS=/media/Data/Libs
,并且由于/media/Data/Libs
可能是一个目录,因此它的格式无法被识别为库文件ld
可能LIBS=/media/Data/Libs
与构建该软件无关,而LIBS
只是您在其他上下文中用于变量的名称 - 这是一个很好的提醒,避免对此类变量使用全大写的名称。
现在,您只需unset LIBS
在 shell 中执行,然后重新运行./configure