ranlib和静态库 [英] ranlib and static library

查看:304
本文介绍了ranlib和静态库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  libmine.a:可能的不读符号:存档没有索引;运行ranlib添加一个

我试着做 ranlib libmine.a 但没有任何变化,它仍然给出了相同的错误。如何解决这个问题?

解决方案

要查看档案中的符号,请使用nm。 b

  nm -s libmine.a 

<输出>



子例程的入口点应标记为T,如

 
00000000 T _sub1
00000019 T _sub2

您在ar中使用了哪些开关静态库?我通常使用ar -r作为

  ar -r libmine.a mine.o yours.o 

如果您仍然遇到问题,请添加-s选项

  ar -s -r libmine.a mine.o yours.o 

另外,请确保路径中没有其他libmine.a文件,或者为您的libmine.a制定明确的路径。链接器可能正在拾取不同的libmine.a。


I am trying to link a static library that I created, but I get this error.

libmine.a: could not read symbols: Archive has no index; run ranlib to add one

I tried to do ranlib libmine.a but nothing changed, it still gives the same error. How can I solve this problem?

解决方案

To see the symbols in an archive, use nm.

nm -s libmine.a

<output>

The entry points to the subroutines should be labled "T" as in

00000000 T _sub1
00000019 T _sub2

What switches did you use in "ar" to make the static library? I usually use "ar -r" as in

ar -r libmine.a mine.o yours.o

If you are still having problems, add the "-s" option

ar -s -r libmine.a mine.o yours.o

Also, be sure that there are no other "libmine.a" files in the path, or make an explicit path to your "libmine.a". It is possible the linker is picking up a different "libmine.a".

这篇关于ranlib和静态库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆