gpt4 book ai didi

编译器测试失败,gcc on redhat

转载 作者:太空宇宙 更新时间:2023-11-04 08:07:11 24 4
gpt4 key购买 nike

我正在尝试通过 lsoft.com 在 redhat 上安装 LISTSERV。软件包自带一个编译器测试,这个测试失败了。

操作系统是:

Red Hat Enterprise Linux Server release 6.8 (Santiago)

拱门是:

x86_64

编译器是:

gcc (GCC) 4.4.7 20120313 (Red Hat 4.4.7-17)

这是完整的“gcc -v”:

Using built-in specs.

Target: x86_64-redhat-linux

Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-bootstrap --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-languages=c,c++,objc,obj-c++,java,fortran,ada --enable-java-awt=gtk --disable-dssi --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-1.5.0.0/jre --enable-libgcj-multifile --enable-java-maintainer-mode --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --disable-libjava-multilib --with-ppl --with-cloog --with-tune=generic --with-arch_32=i686 --build=x86_64-redhat-linux

Thread model: posix

gcc version 4.4.7 20120313 (Red Hat 4.4.7-17) (GCC)

编译器测试.c:

main()
{}

编译测试命令:

gcc -O compilertest.c

错误信息:

/usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../crt1.o: could not read symbols: File in wrong format collect2: ld returned 1 exit status

该文件作为真实文件存在(即不是符号链接(symbolic link)):

-rw-r--r-- 1 root root 1240 Jan 28 2016 /usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../crt1.o

那么,我错过了什么?是否使用 32b 而不是 64b 编译了某些东西?我是缺少某个库还是版本错误?


$ readelf -h /usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../crt1.o
ELF Header:
Magic: 7f 45 4c 46 01 01 01 00 00 00 00 00 00 00 00 00
Class: ELF32
Data: 2's complement, little endian
Version: 1 (current)
OS/ABI: UNIX - System V
ABI Version: 0
Type: REL (Relocatable file)
Machine: Intel 80386
Version: 0x1
Entry point address: 0x0
Start of program headers: 0 (bytes into file)
Start of section headers: 288 (bytes into file)
Flags: 0x0
Size of this header: 52 (bytes)
Size of program headers: 0 (bytes)
Number of program headers: 0
Size of section headers: 40 (bytes)
Number of section headers: 13
Section header string table index: 10

$ env -i PATH=/usr/bin gcc -O compilertest.c
/usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../crt1.o: could not read symbols: File in wrong format
collect2: ld returned 1 exit status

$ gcc -v compilertest.c 
Using built-in specs.
Target: x86_64-redhat-linux
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-bootstrap --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-languages=c,c++,objc,obj-c++,java,fortran,ada --enable-java-awt=gtk --disable-dssi --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-1.5.0.0/jre --enable-libgcj-multifile --enable-java-maintainer-mode --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --disable-libjava-multilib --with-ppl --with-cloog --with-tune=generic --with-arch_32=i686 --build=x86_64-redhat-linux
Thread model: posix
gcc version 4.4.7 20120313 (Red Hat 4.4.7-17) (GCC)
COLLECT_GCC_OPTIONS='-v' '-mtune=generic'
/usr/libexec/gcc/x86_64-redhat-linux/4.4.7/cc1 -quiet -v compilertest.c -quiet -dumpbase compilertest.c -mtune=generic -auxbase compilertest -version -o /tmp/ccGTjhJB.s
ignoring nonexistent directory "/usr/lib/gcc/x86_64-redhat-linux/4.4.7/include-fixed"
ignoring nonexistent directory "/usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../x86_64-redhat-linux/include"
#include "..." search starts here:
#include <...> search starts here:
/usr/local/include
/usr/lib/gcc/x86_64-redhat-linux/4.4.7/include
/usr/include
End of search list.
GNU C (GCC) version 4.4.7 20120313 (Red Hat 4.4.7-17) (x86_64-redhat-linux)
compiled by GNU C version 4.4.7 20120313 (Red Hat 4.4.7-17), GMP version 4.3.1, MPFR version 2.4.1.
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: 2e79a9448b1040fd1e442d3c6bfaea69
COLLECT_GCC_OPTIONS='-v' '-mtune=generic'
as -V -Qy -o /tmp/cc4clAj5.o /tmp/ccGTjhJB.s
GNU assembler version 2.20.51.0.2 (x86_64-redhat-linux) using BFD version version 2.20.51.0.2-5.44.el6 20100205
COMPILER_PATH=/usr/libexec/gcc/x86_64-redhat-linux/4.4.7/:/usr/libexec/gcc/x86_64-redhat-linux/4.4.7/:/usr/libexec/gcc/x86_64-redhat-linux/:/usr/lib/gcc/x86_64-redhat-linux/4.4.7/:/usr/lib/gcc/x86_64-redhat-linux/:/usr/libexec/gcc/x86_64-redhat-linux/4.4.7/:/usr/libexec/gcc/x86_64-redhat-linux/:/usr/lib/gcc/x86_64-redhat-linux/4.4.7/:/usr/lib/gcc/x86_64-redhat-linux/
LIBRARY_PATH=/usr/lib/gcc/x86_64-redhat-linux/4.4.7/:/usr/lib/gcc/x86_64-redhat-linux/4.4.7/:/usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../lib64/:/lib/../lib64/:/usr/lib/../lib64/:/usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../:/lib/:/usr/lib/
COLLECT_GCC_OPTIONS='-v' '-mtune=generic'
/usr/libexec/gcc/x86_64-redhat-linux/4.4.7/collect2 --eh-frame-hdr --build-id -m elf_x86_64 --hash-style=gnu -dynamic-linker /lib64/ld-linux-x86-64.so.2 /usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../crt1.o /usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../crti.o /usr/lib/gcc/x86_64-redhat-linux/4.4.7/crtbegin.o -L/usr/lib/gcc/x86_64-redhat-linux/4.4.7 -L/usr/lib/gcc/x86_64-redhat-linux/4.4.7 -L/usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../lib64 -L/lib/../lib64 -L/usr/lib/../lib64 -L/usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../.. /tmp/cc4clAj5.o -lgcc --as-needed -lgcc_s --no-as-needed -lc -lgcc --as-needed -lgcc_s --no-as-needed /usr/lib/gcc/x86_64-redhat-linux/4.4.7/crtend.o /usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../crtn.o
/usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../crt1.o: could not read symbols: File in wrong format
collect2: ld returned 1 exit status

$ file /usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../crt1.o
/usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../crt1.o: ELF 32-bit LSB relocatable, Intel 80386, version 1 (SYSV), for GNU/Linux 2.6.18, not stripped

最佳答案

此错误信息:

/usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../crt1.o: could not read symbols: File in wrong format collect2: ld returned 1 exit status

表示链接器在预期为 64 位目标文件的地方找到了 32 位目标文件,或者反之亦然。您可以通过使用 file 命令检查有问题的文件来确定是哪一个。 readelf 对此有点矫枉过正,但它也能完成工作。结果我们知道您的文件是 32 位 ELF 目标文件,因此大概编译器需要 64 位文件。

您提供的路径规范化为 /usr/lib/crt1.o。在 RHEL6 上,它属于 32 位 glibc-devel 包(64 位模拟位于 /usr/lib64)。 32 位 ELF 对象正是该文件应有的样子,因此,如果编译器需要一个 64 位对象,那么它就会出现严重错误。

我最好的猜测是,从源代码或其他基于 RPM 的发行版(甚至可能是不同版本的 RHEL)的软件包安装已经为您生成了一个无法使用的环境。如果您在 /usr/bin 以外的地方安装了 GCC 的源代码副本,那么将其删除(至少从路径中删除)可能足以解决您的问题。命令 which gcc 可能有助于确定您是否获得了恶意 gcc 而不是 RHEL 的标准。

否则,最好的办法是删除 gcc 和开发库的所有副本,然后从官方软件包存储库重新安装。要删除和重新安装的主要软件包是“gcc”和“glibc-devel”;删除这些可能会导致其他工具和开发库也被删除。我还建议删除任何“compat-gcc”包。但是,不要试图删除主要的“glibc”包,因为如果您以某种方式设法这样做,它会使您的系统无法运行。

关于编译器测试失败,gcc on redhat,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41964505/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com