无法读取符号:存档没有索引;运行ranlib添加一个 [英] could not read symbols: Archive has no index; run ranlib to add one
问题描述
我试图用 $ b
ar -r -c -s libtestlib.a * .o
在本教程中给出 http://matrixprogramming.com/Tools/CompileLink.html
但是在链接库后出现错误
g ++ -o uni2asc uni2asc.o -L ../模块-ltestlib
../Modules/libtestlib.a:无法读取符号:存档没有索引;运行ranlib添加一个
collect2:ld返回1退出状态
我尝试使用ranlib也但仍然出现错误...
im正在使用ubuntu9.10
请为我提供一些解决方案
你的存档命令看起来不错,你可以尝试下面的内容。
1)获取存档/静态库中的目标文件
ar -t libtestlib.a
<2>对于步骤1中的每个目标文件(比如foo.o)
file foo.o
这会告诉你的目标文件的格式。如果目标文件是针对其他平台编译的,则会导致无法为存档构建索引。
为了解决这个问题,你需要重新编译这些文件。
3)对于步骤1中的每个目标文件,执行
nm foo.o
这将列出从文件导出的符号。
i tried making library with
ar -r -c -s libtestlib.a *.o
as given in this tutorial http://matrixprogramming.com/Tools/CompileLink.html
But on linking with library following error comes
g++ -o uni2asc uni2asc.o -L../Modules -ltestlib
../Modules/libtestlib.a: could not read symbols: Archive has no index; run ranlib to add one
collect2: ld returned 1 exit status
i tried with ranlib also but still the error comes.. im working with ubuntu9.10 Please suggest me some solution for this
Your archive command looks fine, can you try the following. 1) Get the object files in the archive/static library
ar -t libtestlib.a
2) For each object file (say foo.o) from step 1
file foo.o
This will tell you the format of the object file. If the object file was compiled for a different platform, this would cause a failure to build the index for the archive.
To correct this you would need to recompile these files.
3) For each object file from step 1, do
nm foo.o
This will list the symbols exported from the file.
这篇关于无法读取符号:存档没有索引;运行ranlib添加一个的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!