gpt4 book ai didi

linux - g++ 抛出文件无法识别 : File format not recognized error

转载 作者:IT王子 更新时间:2023-10-29 00:32:30 25 4
gpt4 key购买 nike

使用命令 g++ -o test -L 出现以下错误。 -l pq

libpq.so: file not recognized: File format not recognized

#file libpq.so
libpq.so: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), not stripped

gcc 版本 4.1.2 20070115 (SUSE Linux)

如果我尝试使用 -l dbodbc 而不是 -l pq,我会遇到同样的错误。

请注意,test.c 是一个简单的 hello world 程序。

提前致谢。

最佳答案

file/usr/bin/g++ 告诉你 g++ 本身是一个 64 位可执行文件,即它在 64 位机器上运行,它 没有告诉您 g++ 可以编译 64 位代码(这不太可能,但它可能是一个完全不同处理器的交叉编译器!)使用g++ -vg++ -dumpmachine 找出它为哪个目标生成可执行文件。

G++ 实际上并没有使用那个库,它只是将 -l 选项传递给链接器,所以错误来自链接器,ld

如果 ldobjdump 都说他们无法识别库,但同一个文件在不同的机器上没问题,我会尝试更新或重新安装 binutils包,同时提供了ldobjdump

您可能安装了 32 位的 binutils,因此它的 ldobjdump 无法理解 x86_64 库。确保安装了 64 位(即 x86_64)binutils RPM。

关于linux - g++ 抛出文件无法识别 : File format not recognized error,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14404445/

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