libpng: C compiler cannot create executables

5,050

As we can see from the config.log, gcc is being invoked with an additional argument /media/Data/Libs which it is interpreting as a library file that it should attempt to link:

configure:3333: gcc    conftest.c /media/Data/Libs >&5
/usr/bin/ld: cannot find /media/Data/Libs: File format not recognized

Looking further, we can see that this is being picked up from your environment via autoconf's 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=

This suggests you have defined an environment variable LIBS=/media/Data/Libs, and since /media/Data/Libs is presumably a directory, its format is unrecognized as a library file by ld

Likely LIBS=/media/Data/Libs is unrelated to building this software and LIBS is simply a name you have used for a variable in some other context - this is a good reminder to avoid all-caps names for such variables.

For now, you can just execute unset LIBS in the shell and then re-run ./configure

Share:
5,050

Related videos on Youtube

anne
Author by

anne

Updated on September 18, 2022

Comments

  • anne
    anne over 1 year

    I am trying to call ./configure command. But, it shows this error:

    C compiler cannot create executables.
    

    Here the output:

    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
    

    I checked the config.log, it can detect gcc installed but it can't find conftest.c file. I already tried:

    sudo apt-get update
    sudo apt-get install build-essential
    

    But it still shows the error. I also checked that my libc6 is already installed in the newest version.

    How to solve it?

    This is the 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
    
    • steeldriver
      steeldriver about 6 years
      As you can see in the log, it tries to run gcc with /media/Data/Libs as a file argument - which it seems to be getting from your environment (ac_cv_env_LIBS_value=/media/Data/Libs). You need to find out how and where that is getting set. What does printenv | grep LIB say?
    • Melebius
      Melebius about 6 years
      The configure script is specific to a project, you should contact its maintainer.
    • anne
      anne about 6 years
      @steeldriver the output of printenv | grep LIB is /media/Data/Libs
    • steeldriver
      steeldriver about 6 years
      Is it /media/Data/Libs - or LIBS=/media/Data/Libs?
    • anne
      anne about 6 years
      @steeldriver It is LIBS=/media/Data/Libs
    • steeldriver
      steeldriver about 6 years
      Right... and why do you have that variable set? If it's just a personal variable, then rename it (generally, it's best to avoid all-caps names for user-defined shell/environment variables - for exactly this reason). If you don't need LIBS to be defined that way, then execute unset LIBS in the shell and then run ./configure again.
    • anne
      anne about 6 years
      @steeldriver it's working now after I execute unset LIBS . Thanks a lot!
    • steeldriver
      steeldriver about 6 years
      OK that's good - I will write up an answer for the record