./configure fails - C compiler cannot create executables.

Discussion in 'Mac Programming' started by m.prebble, Jan 17, 2010.

  1. m.prebble macrumors newbie

    Joined:
    Jan 17, 2010
    #1
    Hi,

    Normally google is my friend when it comes to these things, but now even it has failed me. I apologise in advance if this has been answered elsewhere.

    A long-time PC/linux user, have recently switched to Mac (now they are Intel!) Am running Lepoard, and trying to compile several tool chains (cross compilers for ARM (2.95) and CRIS (1.64) architectures.

    After getting over the "unrecognised host" stumbling block, the ./configure operation fails again:

    Code:
    [Beginning truncated ]*
    Configuring opcodes...
    loading cache ../config.cache
    checking host system type... i386-apple-darwin10.2.0
    checking target system type... arm-unknown-elf
    checking build system type... i386-apple-darwin10.2.0
    checking for gcc... (cached) gcc
    checking whether the C compiler (gcc -g -O2 -W -Wall ) works... yes
    checking whether the C compiler (gcc -g -O2 -W -Wall ) is a cross-compiler... no
    checking whether we are using GNU C... (cached) yes
    checking whether gcc accepts -g... (cached) yes
    checking for POSIXized ISC... no
    checking for a BSD compatible install... (cached) /usr/bin/install -c
    checking whether build environment is sane... yes
    checking whether make sets ${MAKE}... (cached) yes
    checking for working aclocal... found
    checking for working autoconf... found
    checking for working automake... found
    checking for working autoheader... found
    checking for working makeinfo... found
    checking for ar... (cached) ar
    checking for ranlib... (cached) ranlib
    checking for ranlib... (cached) ranlib
    checking for ld used by GCC... (cached) /usr/libexec/gcc/i686-apple-darwin10/4.2.1/ld
    checking if the linker (/usr/libexec/gcc/i686-apple-darwin10/4.2.1/ld) is GNU ld... (cached) no
    checking for BSD-compatible nm... (cached) /usr/bin/nm
    checking whether ln -s works... (cached) yes
    loading cache ../config.cache within ltconfig
    checking for object suffix... o
    checking for executable suffix... (cached) .dSYM
    checking for gcc option to produce PIC... -fPIC
    checking if gcc PIC flag -fPIC works... yes
    checking if gcc supports -c -o file.o... yes
    checking if gcc supports -c -o file.lo... yes
    checking if gcc supports -fno-rtti -fno-exceptions ... no
    checking if gcc static flag -static works... none
    checking if the linker (/usr/libexec/gcc/i686-apple-darwin10/4.2.1/ld) is GNU ld... no
    checking whether the linker (/usr/libexec/gcc/i686-apple-darwin10/4.2.1/ld) supports shared libraries... no
    checking command to parse /usr/bin/nm output... rm: conftest.dSYM: is a directory
    ok
    checking how to hardcode library paths into programs... unsupported
    checking for /usr/libexec/gcc/i686-apple-darwin10/4.2.1/ld option to reload object files... -r
    checking dynamic linker characteristics... no
    checking if libtool supports shared libraries... no
    checking whether to build shared libraries... no
    checking whether to build static libraries... yes
    checking for objdir... .libs
    creating libtool
    loading cache ../config.cache
    checking whether to enable maintainer-specific portions of Makefiles... no
    checking for Cygwin environment... (cached) no
    checking for mingw32 environment... (cached) no
    checking for executable suffix... (cached) .dSYM
    checking for gcc... (cached) gcc
    checking whether the C compiler (gcc -g -O2 -W -Wall ) works... no
    configure: error: installation or configuration problem: C compiler cannot create executables.
    
    Examining the config.log, there are A LOT of errors about conftest.dSYM being a directory. I attach the tail of the failing config.log

    Code:
    marcus-mbp:opcodes marcus$ cat config.log 
    This file contains any messages produced by compilers while
    running configure, to aid debugging if configure makes a mistake.
    
    configure:605: checking host system type
    configure:626: checking target system type
    configure:644: checking build system type
    configure:669: checking for gcc
    configure:782: checking whether the C compiler (gcc -g -O2 -W -Wall ) works
    configure:798: gcc -o conftest -g -O2 -W -Wall   conftest.c  1>&5
    configure:795: warning: return type defaults to 'int'
    configure:824: checking whether the C compiler (gcc -g -O2 -W -Wall ) is a cross-compiler
    configure:829: checking whether we are using GNU C
    configure:857: checking whether gcc accepts -g
    configure:889: checking for POSIXized ISC
    configure:927: checking for a BSD compatible install
    configure:980: checking whether build environment is sane
    configure:1037: checking whether make sets ${MAKE}
    configure:1083: checking for working aclocal
    configure:1096: checking for working autoconf
    configure:1109: checking for working automake
    configure:1122: checking for working autoheader
    configure:1135: checking for working makeinfo
    configure:1158: checking for ar
    configure:1190: checking for ranlib
    configure:1328: checking for ranlib
    configure:1367: checking for ld used by GCC
    configure:1429: checking if the linker (/usr/libexec/gcc/i686-apple-darwin10/4.2.1/ld) is GNU ld
    configure:1445: checking for BSD-compatible nm
    configure:1481: checking whether ln -s works
    ltconfig:603: checking for object suffix
    ltconfig:604: gcc -c -g -O2 -W -Wall  conftest.c 1>&5
    ltconfig:776: checking if gcc PIC flag -fPIC works
    ltconfig:777: gcc -c -g -O2 -W -Wall -fPIC -DPIC  conftest.c 1>&5
    ltconfig:829: checking if gcc supports -c -o file.o
    ltconfig:830: gcc -c -g -O2 -W -Wall -o out/conftest2.o  conftest.c 1>&5
    ltconfig:862: checking if gcc supports -c -o file.lo
    ltconfig:863: gcc -c -g -O2 -W -Wall -c -o conftest.lo  conftest.c 1>&5
    ltconfig:914: checking if gcc supports -fno-rtti -fno-exceptions
    ltconfig:915: gcc -c -g -O2 -W -Wall -fno-rtti -fno-exceptions -c conftest.c  conftest.c 1>&5
    ltconfig:958: checking if gcc static flag -static works
    ltconfig:959: gcc -o conftest -g -O2 -W -Wall   -static conftest.c  1>&5
    conftest.c:1: warning: return type defaults to 'int'
    ld: library not found for -lcrt0.o
    collect2: ld returned 1 exit status
    ltconfig:1635: checking if global_symbol_pipe works
    ltconfig:1636: gcc -c -g -O2 -W -Wall  conftest.c 1>&5
    conftest.c:9: warning: return type defaults to 'int'
    ltconfig:1639: eval "/usr/bin/nm conftest.o | sed -n -e 's/^.*[ 	]\([BCDEGRST]\)[ 	][ 	]*\(\)\([_A-Za-z][_A-Za-z0-9]*\)$/\1 \2\3 \3/p' > conftest.nm"
    cannot find nm_test_var in conftest.nm
    ltconfig:1635: checking if global_symbol_pipe works
    ltconfig:1636: gcc -c -g -O2 -W -Wall  conftest.c 1>&5
    conftest.c:9: warning: return type defaults to 'int'
    ltconfig:1639: eval "/usr/bin/nm conftest.o | sed -n -e 's/^.*[ 	]\([BCDEGRST]\)[ 	][ 	]*\(_\)\([_A-Za-z][_A-Za-z0-9]*\)$/\1 \2\3 \3/p' > conftest.nm"
    ltconfig:1691: gcc -o conftest -g -O2 -W -Wall -fno-builtin   conftest.c conftstm.o 1>&5
    conftest.c:6: warning: 'main' is usually a function
    configure:1714: checking whether to enable maintainer-specific portions of Makefiles
    configure:1737: checking for Cygwin environment
    configure:1770: checking for mingw32 environment
    configure:1801: checking for executable suffix
    configure:1837: checking for gcc
    configure:1950: checking whether the C compiler (gcc -g -O2 -W -Wall ) works
    configure:1966: gcc -o conftest.dSYM -g -O2 -W -Wall   conftest.c  1>&5
    configure:1963: warning: return type defaults to 'int'
    ld: can't open output file for writing: conftest.dSYM, errno=21
    collect2: ld returned 1 exit status
    configure: failed program was:
    
    #line 1961 "configure"
    #include "confdefs.h"
    
    main(){return(0);}
    
    
    This is frustrating as, errno 22 is "Is a directory". Why does it create a directory? I tried running a small script that replaced "rm -f conftest.*" with rm -rf conftest*" to remove these directories, but no joy.

    I would appreciate if someone could advise what might be wrong.
    p.s. As these are toolchains, the configure needs to be run as root.
    The error is the same for both tool chains.

    Kernel version:
    Code:
    marcus-mbp:srcs marcus$ uname -v
    Darwin Kernel Version 10.2.0: Tue Nov  3 10:37:10 PST 2009; root:xnu-1486.2.11~1/RELEASE_I386
    
    Thanks in advance,
     
  2. KnightWRX macrumors Pentium

    KnightWRX

    Joined:
    Jan 28, 2009
    Location:
    Quebec, Canada
    #2
    The only help I can provide is that ld can't create the file because a directory exists with the same name :

    Code:
    $ cat test.c
    #include <stdlib.h>
    
    int main()
    {
    	return EXIT_SUCCESS;
    }
    $ gcc -o test test.c
    $ rm test
    $ mkdir test
    $ gcc -o test test.c
    ld: can't open output file for writing: test, errno=21
    collect2: ld returned 1 exit status
    
    This is not really a programming question, but a package compiling/installing question I'm guessing. Which package are you trying to build exactly ? Maybe if we can download it and try it out, we can see if there's a bug somewhere in the autoconf generated script.

    Have you tried grabbing the package from CVS/SVN and using OS X versions automake/autoconf to rebuild the build scripts ?
     
  3. m.prebble thread starter macrumors newbie

    Joined:
    Jan 17, 2010
    #3
  4. lloyddean macrumors 6502a

    Joined:
    May 10, 2009
    Location:
    Des Moines, WA
    #4
    If any of the following items are what you're after look into MacPorts.

    arm-aout-binutils @2.17 (cross, devel)
    FSF Binutils for arm-aout cross development

    arm-aout-gcc @3.3.6 (cross, devel)
    gcc cross-compilers for arm-aout, with newlib runtime library.

    arm-elf-binutils @2.20.51.0.2 (cross, devel)
    FSF Binutils for arm-elf cross development

    arm-elf-gcc @4.3.2 (cross, devel)
    gcc cross-compilers for arm-elf, with newlib runtime library.

    arm-elf-gcc3 @3.4.6 (cross, devel)
    gcc 3.x cross-compilers for arm-elf, with newlib runtime library.

    arm-none-linux-gnueabi-binutils @2005q3-2 (cross, devel)
    FSF Binutils for arm-none-linux-gnueabi cross development, with Code Sourcery patches (for Nokia Internet Tablet)

    arm-none-linux-gnueabi-gcc @2005q3-2 (cross, devel)
    gcc 3.x cross-compilers for arm-none-linux-gnueabi.

    arm-none-linux-gnueabi-runtime @cs2005q3.2 (cross, devel)
    headers and precompiled libraries arm-none-linux-gnueabi (Nokia Internet Tablet), obtained from scratchbox.

    arm-rtems-binutils @2.18 (cross, devel)
    FSF Binutils for arm-rtems cross development

    arm-rtems-gcc @4.2.3 (cross, devel)
    gcc cross-compilers for arm-rtems, with newlib runtime library.
     
  5. m.prebble thread starter macrumors newbie

    Joined:
    Jan 17, 2010
    #5
    Hi, I tried macports first actually.
    The problem is, the target is a uClinux based MMU-less CPU so the source needs some patching first!

    Also, it doesn't help me for building the other toolchain for CRIS.
    Ultimately I want to fix the build problem on my machine.

    Any other ideas?

    Thanks!
     
  6. nhtshot macrumors newbie

    Joined:
    Mar 7, 2010
    Location:
    Overland Park, KS
    #6
    I'm having the same issue building a toolchain for m68hc12.

    The issue is debugging symbols on MacOS are put into a directory called dSYM instead of a file.

    This makes autoconf go batty. Supposedly, they patched autoconf, I've found the patches. But, apparently those MacOS specific patches didn't make it into the version that Apple is distributing with Xcode.

    Cute, eh?

    I haven't managed to get mine working yet, but I should be able to sort this out today and I'll let ya know how I did it.
     
  7. m.prebble thread starter macrumors newbie

    Joined:
    Jan 17, 2010
    #7
    Thank you, this is the most useful reply to this thread!! Cute is not quite the word I would use though ... I got so frustrated with not being able to build either arm or cris toolchains that I installed Linux. Typical apple, why make it easy?

    But please, please do share your experiences if you do get it to work. I appreciate your time,

    Marcus
     
  8. nhtshot macrumors newbie

    Joined:
    Mar 7, 2010
    Location:
    Overland Park, KS
    #8
    This was really easy to fix once I did a little googling on how autoconf works.

    Apparently, the fix IS in the xcode autoconf, the issue is that the ./configure script is built by the autoconf of the person packaging the software. Simply delete configure and run autoconf. It will recreate it and you'll be good to go.

    At least, this worked for compiling binutils for 68HC12.
     
  9. nhtshot macrumors newbie

    Joined:
    Mar 7, 2010
    Location:
    Overland Park, KS
    #9
    Well, it was able to compile, but libiberty crapped all over itself.

    I managed to track it down to an issue with the install-sh included with the package I was using. Around this time I found that fink has a toolchain for the controller I'm using.

    As much as I enjoy the challenge of building my own stuff... I've got real work to do.

    http://www.finkproject.org/

    http://pdb.finkproject.org/pdb/package.php/m681x-binutils
     
  10. flydanofly macrumors newbie

    Joined:
    Feb 18, 2009
    #10
    I was trying to compile older versions of PHP (5.2.[1-4]) and was having this problem. Deleting 'configure', running 'autoconf', then running 'configure' worked beatuifully. Thanks!
     
  11. JasonHears macrumors newbie

    Joined:
    Oct 28, 2007
    #11
    Fixed

    Just wanted to throw in my thanks to nhtshot! I was having trouble compiling PHP 5.2 on Mac OS X 10.6. It was throwing an error saying that the compiler couldn't write the executable. Then the configure.log stated ld: can't open output file for writing: conftest.dSYM. I tried the autoconf trick and that fixed it! So I'm here to say thanks and add a little more SEO bait to this thread so anyone having my same issue might find the solution even quicker.

    Thanks!!
     

Share This Page