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

前端 未结 4 598
生来不讨喜
生来不讨喜 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

    I ran into the exact same problem when trying to compile the NBIS libraries. There is an option for

    make install LIBNBIS=yes
    

    which creates a single archive containing the other archive files. The gcc linker does not handle this gracefully and just emits the Archive has no index message. The fix is to leave the archives as separate files

    make install LIBNBIS=no
    

    Then just link the application to the required archive(s). The archive feed order is important to be sure that the linker identifies the required dependencies, then resolves them as it processes the .a files.

提交回复
热议问题