配置脚本抛出gcc错误

我正在尝试在Ubuntu 12.04上编译SDL-1.2.15

http://www.linuxfromscratch.org/blfs/view/svn/multimedia/sdl.html

安装指南说我需要先调用configure文件。 查看注释,似乎需要创建一个用于编译库的makefile。 所以,我先输入:

sudo sh ./configure 

我收到以下错误消息:

 checking build system type... i686-pc-linux-gnu checking host system type... i686-pc-linux-gnu checking for gcc... gcc checking for C compiler default output file name... a.out checking whether the C compiler works... configure: error: cannot run C compiled programs. If you meant to cross compile, use `--host'. See `config.log' for more details. 

我检查了日志文件(见下文),但无法确定底层问题。 关于如何进行的任何想法?


此文件包含编译器在运行configure时生成的任何消息,以便在configure出错时帮助调试。

它是由configure创建的,由GNU Autoconf 2.61生成。 调用命令行是

  $ ./configure ## --------- ## ## Platform. ## ## --------- ## hostname = ubuntu uname -m = i686 uname -r = 3.2.0-24-generic-pae uname -s = Linux uname -v = #39-Ubuntu SMP Mon May 21 18:54:21 UTC 2012 /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: /usr/local/sbin PATH: /usr/local/bin PATH: /usr/sbin PATH: /usr/bin PATH: /sbin PATH: /bin ## ----------- ## ## Core tests. ## ## ----------- ## configure:2136: checking build system type configure:2154: result: i686-pc-linux-gnu configure:2176: checking host system type configure:2191: result: i686-pc-linux-gnu configure:2261: checking for gcc configure:2277: found /usr/bin/gcc configure:2288: result: gcc configure:2526: checking for C compiler version configure:2533: gcc --version >&5 gcc (Ubuntu/Linaro 4.6.3-1ubuntu5) 4.6.3 Copyright (C) 2011 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:2536: $? = 0 configure:2543: gcc -v >&5 Using built-in specs. COLLECT_GCC=gcc COLLECT_LTO_WRAPPER=/usr/lib/gcc/i686-linux-gnu/4.6/lto-wrapper Target: i686-linux-gnu Configured with: ../src/configure -v --with-pkgversion='Ubuntu/Linaro 4.6.3-1ubuntu5' --with-bugurl=file:///usr/share/doc/gcc-4.6/README.Bugs --enable-languages=c,c++,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-4.6 --enable-shared --enable-linker-build-id --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.6 --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-gnu-unique-object --enable-plugin --enable-objc-gc --enable-targets=all --disable-werror --with-arch-32=i686 --with-tune=generic --enable-checking=release --build=i686-linux-gnu --host=i686-linux-gnu --target=i686-linux-gnu Thread model: posix gcc version 4.6.3 (Ubuntu/Linaro 4.6.3-1ubuntu5) configure:2546: $? = 0 configure:2553: gcc -V >&5 gcc: error: unrecognized option '-V' gcc: fatal error: no input files compilation terminated. configure:2556: $? = 4 configure:2579: checking for C compiler default output file name configure:2606: gcc conftest.c >&5 configure:2609: $? = 0 configure:2647: result: a.out configure:2664: checking whether the C compiler works configure:2674: ./a.out ./configure: line 2675: ./a.out: Permission denied configure:2677: $? = 126 configure:2686: error: cannot run C compiled programs. If you meant to cross compile, use `--host'. See `config.log' for more details. 

您以root身份启动了配置脚本(通过sudo)。 它正在测试您的编译器并创建了一个只能由root用户执行的文件。 因此,尝试以普通用户身份执行失败。

通常,在构建软件时不需要sudo,只在安装时才使用它。

更新:仔细检查后,看起来您至少运行了两次配置脚本:首先使用sudo然后不使用。 您可能忘记了清理,因此有一个陈旧的a.out文件属于root用户,不能由非特权用户执行。

Update2:根据下面的评论,我必须对发生的事情添加另一个解释。 您试图在非POSIX文件系统上编译您的包。 像FAT32这样的文件系统不存储文件权限,这就是你无法运行./configure ,并且脚本无法运行a.out来检查你的编译器是否正常工作。

首先安装必备包。

sudo apt-get install build-essential

然后试试

如果再次出现错误,请尝试此操作

sudo ./configure