无法识别文件格式;视为链接描述文件

发布于 2024-10-30 15:54:03 字数 815 浏览 1 评论 0原文

我是 gcc 编译器的新手。

我的朋友为我编写了这个脚本(图形过滤器),但我无法使用它,因为我收到一些错误。

我有 2 个目录和一个 C 文件:

-dir- include --> basics.h common.h freeimage.h hqx.h imageIO.h pcxIO.h    
-dir- lib --> libfreeimage-3.13.1.so libfreeimage.a libfreeimage.so.3 libhqx.a libhqx.so libhqx.so.1 libhqx.so.1.0.0  
scaling.c

我尝试使用此命令进行编译:

gcc scaling.c -I./include -L./lib -lm -lfreeimage -lhqx -lstdc++ -o filter

但我收到此错误:

/usr/lib/gcc/i486-slackware-linux/4.2.4/../../../../i486-slackware-linux/bin/ld:./lib/libhqx.so: file format not recognized; treating as linker script
/usr/lib/gcc/i486-slackware-linux/4.2.4/../../../../i486-slackware-linux/bin/ld:./lib/libhqx.so:1: syntax error
collect2: ld returned 1 exit status

提前感谢我的英语。

i'm new on gcc compiler.

My friend wrote this script (graphic filter) for me but i can't use it because i receive some error.

I have 2 directory and a C file:

-dir- include --> basics.h common.h freeimage.h hqx.h imageIO.h pcxIO.h    
-dir- lib --> libfreeimage-3.13.1.so libfreeimage.a libfreeimage.so.3 libhqx.a libhqx.so libhqx.so.1 libhqx.so.1.0.0  
scaling.c

i try to compile with this command:

gcc scaling.c -I./include -L./lib -lm -lfreeimage -lhqx -lstdc++ -o filter

But i receive this error:

/usr/lib/gcc/i486-slackware-linux/4.2.4/../../../../i486-slackware-linux/bin/ld:./lib/libhqx.so: file format not recognized; treating as linker script
/usr/lib/gcc/i486-slackware-linux/4.2.4/../../../../i486-slackware-linux/bin/ld:./lib/libhqx.so:1: syntax error
collect2: ld returned 1 exit status

Thanks in advance and sorry for my english.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

故人如初 2024-11-06 15:54:03

我昨天遇到了类似的问题,我认为您的 libhqx.so 是指向 libhqx.so.1.0.0 或您朋友机器上的 libhqx.so.1 的符号链接,当您复制此文件时,此链接已损坏。 (至少我们系统中的情况是这样,在我们删除 .so 文件并创建正确的符号链接后问题就解决了)

I had a similar problem yesterday, and I think your libhqx.so was a symbolic link to libhqx.so.1.0.0 or to libhqx.so.1 in your friend's machine, and when you copied this files, this link had broken. (at least that was the situation in our system, and the problem solved after we remove the .so file, and create the right symbolic link)

请持续率性 2024-11-06 15:54:03

链接器会将任何看起来不像目标文件或库的文件视为链接器脚本,其中包含指定如何完成链接的命令。诸如加载地址、节定义等之类的东西。

显然 libhqx.so 看起来不像您系统上的共享库。我猜它是在你朋友的系统上构建的?

要了解文件是什么,请使用 file 命令。您应该得到类似的信息:

main% file /lib/libc-2.11.2.so 
/lib/libc-2.11.2.so: ELF 32-bit LSB shared object, Intel 80386, version 1 (GNU/Linux), dynamically linked (uses shared libs), for GNU/Linux 2.6.18, not stripped

如果没有,您将必须构建或找到与您的系统兼容的库。

The linker will treat any file that doesn't look like an object file or library as a linker script containing commands to specify how linking should be done. Things like load addresses, section definitions, etc.

Apparently libhqx.so doesn't look like a shared library on you system. I assume it was built on your friend's system?

To get a clue about what the file is, use the file command. You should get something like:

main% file /lib/libc-2.11.2.so 
/lib/libc-2.11.2.so: ELF 32-bit LSB shared object, Intel 80386, version 1 (GNU/Linux), dynamically linked (uses shared libs), for GNU/Linux 2.6.18, not stripped

If not, you'll have to build or find a library compatible with your system.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文