/lib/libmatrix.a: file not recognized: File format not recognized collect2: ld returned 1 exit statu

本文探讨了在从Cygwin环境移植到Ubuntu环境时遇到的跨平台库编译错误,特别是关于libmatrix.a文件格式不被识别的问题。文章详细介绍了如何确保库文件与目标平台兼容,并强调了重新编译库的重要性。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

I'm trying to compile a makefile which includes the following line:

gcc -I. -I/home/usr/Documents/MTV/include -ggdb3 -Wall -O2 -o ascii2bin.c \
    -L. -L../lib -lmatrix -lseq_io -lpic -lm

And this is what I get:

../lib/libmatrix.a: file not recognized: File format not recognized
collect2: ld returned 1 exit status

Any idea on what might happen to libmatrix.a? How can I read what's inside libmatrix.a? I tried using the 'ar -t' command, but it also says file format not recognized.

The project was compiled on Cygwin before by others, and now I'm using ubuntu gcc to try to redo it, could this be the problem?

share improve this question
 
 
How are you trying to "compile a Makefile"? –  user529758  Jun 17 '13 at 17:35
 
@H2CO3 make is a compiler. –  Casey  Jun 17 '13 at 17:36
 
well, i meant using the command 'make'. –  nineties  Jun 17 '13 at 17:36
4  
@Casey euh, no, it's a build automation tool. Not even remotely a compiler. –  user529758  Jun 17 '13 at 17:37
4  
Does file ../lib/libmatrix.a tell you anything useful? –  twalberg  Jun 17 '13 at 18:01

1 Answer

up vote 2 down vote accepted

A library file built for cygwin will not work on linux.

The library itself must be recompiled from source to match the details (ABI, dynamic system library dependencies, etc) of the system on which it is intended to be used.

Cygwin tries to be source compatible with Linux, so if you have the source rebuilding may be straightforward. But it is not binary-compatible, and libraries are basically binary building blocks with metadata to permit linking them together.

share improve this answer
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值