sudo apt-get 安装 build-essential

sudo apt-get 安装 build-essential

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

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

安装指南说我需要先调用配置文件。查看注释,这似乎是创建用于编译库的 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.

答案1

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

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

更新:仔细检查后,似乎您至少运行了两次 configure 脚本:第一次使用 sudo,第二次没有。您可能忘记清理,因此存在一个属于 root 的过时 a.out 文件,非特权用户无法执行该文件。

更新 2:根据下面的评论,我必须对发生的事情做出另一种解释。您尝试在非 POSIX 文件系统上编译您的软件包。FAT32 等文件系统不存储文件权限,这就是为什么您无法运行./configure并且脚本无法运行 a.out 来检查您的编译器是否正常工作。

答案2

首先安装必需的包。

sudo apt-get 安装 build-essential

然后尝试

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

sudo./configure

相关内容