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

前端 未结 4 683
生来不讨喜
生来不讨喜 2020-12-08 07:48

i tried making library with

ar -r -c -s libtestlib.a *.o

as given in this tutorial http://matrixprogramming.com/Tools/CompileLink.html

4条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-08 08:16

    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.

提交回复
热议问题