Gcc 为什么在尝试配置make时出现此错误?

Gcc 为什么在尝试配置make时出现此错误?,gcc,gnu-make,Gcc,Gnu Make,我需要安装make作为一个静态链接程序,这样我就可以安装一个更新版本的glibc,而不会导致系统崩溃。在使用tar解包并在目录中传递/configure后,我得到以下配置错误: 配置:4216:错误:在“/home/anon/make-4.3”中: 配置:4218:错误:C编译器无法创建可执行文件 有关更多详细信息,请参阅config.log 以下是我的config.log中的一些信息: ## ----------- ## ## Core tests. ## ## ----------- ##

我需要安装make作为一个静态链接程序,这样我就可以安装一个更新版本的glibc,而不会导致系统崩溃。在使用tar解包并在目录中传递
/configure
后,我得到以下配置错误:

配置:4216:错误:在“/home/anon/make-4.3”中:
配置:4218:错误:C编译器无法创建可执行文件
有关更多详细信息,请参阅config.log

以下是我的config.log中的一些信息:

## ----------- ##
## Core tests. ##
## ----------- ##

configure:3177: checking for a BSD-compatible install
configure:3245: result: /usr/bin/install -c
configure:3256: checking whether build environment is sane
configure:3311: result: yes
configure:3460: checking for a thread-safe mkdir -p
configure:3499: result: /usr/bin/mkdir -p
configure:3506: checking for gawk
configure:3522: found /usr/bin/gawk
configure:3533: result: gawk
configure:3544: checking whether make sets $(MAKE)
configure:3566: result: yes
configure:3595: checking whether make supports nested variables
configure:3612: result: yes
configure:3744: checking whether make supports the include directive
configure:3759: make -f confmf.GNU && cat confinc.out
this is the am__doit target
configure:3762: $? = 0
configure:3781: result: yes (GNU style)
configure:3851: checking for gcc
configure:3867: found /usr/bin/gcc
configure:3878: result: gcc
configure:4107: checking for C compiler version
configure:4116: gcc --version >&5
gcc (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0
Copyright (C) 2019 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:4127: $? = 0
configure:4116: gcc -v >&5
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/9/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none:hsa
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 9.3.0-17ubuntu1~20.04' --with-bugurl=file:///usr/share/doc/gcc-9/README.Bugs --enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++,gm2 --prefix=/usr --with-gcc-major-version-only --program-suffix=-9 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-plugin --enable-default-pie --with-system-zlib --with-target-system-zlib=auto --enable-objc-gc=auto --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none=/build/gcc-9-HskZEa/gcc-9-9.3.0/debian/tmp-nvptx/usr,hsa --without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 9.3.0 (Ubuntu 9.3.0-17ubuntu1~20.04) 
configure:4127: $? = 0
configure:4116: gcc -V >&5
gcc: error: unrecognized command line option '-V'
gcc: fatal error: no input files
compilation terminated.
configure:4127: $? = 1
configure:4116: gcc -qversion >&5
gcc: error: unrecognized command line option '-qversion'; did you mean '--version'?
gcc: fatal error: no input files
compilation terminated.
configure:4127: $? = 1
configure:4147: checking whether the C compiler works
configure:4169: gcc -static -02 -g   conftest.c  >&5
gcc: error: unrecognized command line option '-02'
configure:4173: $? = 1
configure:4211: result: no
configure: failed program was:
| /* confdefs.h */
| #define PACKAGE_NAME "GNU make"
| #define PACKAGE_TARNAME "make"
| #define PACKAGE_VERSION "4.3"
| #define PACKAGE_STRING "GNU make 4.3"
| #define PACKAGE_BUGREPORT "bug-make@gnu.org"
| #define PACKAGE_URL "http://www.gnu.org/software/make/"
| #define PACKAGE "make"
| #define VERSION "4.3"
| /* end confdefs.h.  */
| 
| int
| main ()
| {
| 
|   ;
|   return 0;
| }
configure:4216: error: in '/home/anon/make-4.3':
configure:4218: error: C compiler cannot create executables
See config.log' for more details

为什么会发生这种情况?

这似乎是一个gcc问题,而不是制造问题。您的GCC命令行似乎不喜欢这个选项。这对我很有用:

$ gcc --version
gcc (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0

$ echo 'int main() { return 0; }' > foo.c

$ gcc -static -O2 -g foo.c

$ ldd a.out
        not a dynamic executable
这对你不管用吗?您使用的是什么版本的GCC?什么操作系统

但是,选择不同的方法来处理此问题可能比构建静态make更简单

为什么不将当前libc复制到其他地方,然后运行make with
LD\u LIBRARY\u PATH
,如:

$ mkdir ~/oldlibc
$ cp /lib/x86_64-linux-gnu/libdl.so.2 /lib/x86_64-linux-gnu/libc.so.6 ~/oldlibc
$ LD_LIBRARY_PATH=$HOME/oldlibc make

或者类似的?使用
ldd/usr/bin/make
查看您的版本链接的共享库以及它们的来源。

我在Ubuntu上使用的是gcc的9.3.0版,我尝试了您发布的命令,gcc成功地创建了foo文件和安装文件。但是为什么它在使用
/配置
时不这样做呢?这可能与我试图使用的文件有关吗?»C编译器无法创建可执行文件««:您已经完全安装了gcc吗<代码>sudo apt install g++
将安装依赖项,使gcc完全工作。例如,
libc6-dev、linux-libc-dev
等等,我无法解释。如果运行
type-a gcc
,它是否只显示一个版本?也许你有一个GCC的别名或函数包装器,或者可能有多个版本并且你的路径被重置了?Knud Larsen:是的,我已经有了g++以及依赖项,正如我们所说,我正在安装一些东西,当使用
/configure
make
make install
时没有问题。疯狂科学家:运行
后,键入-a gcc
我得到
gcc is/usr/bin/gcc
gcc is/bin/gcc