本文介绍了聚合静态库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我尝试将多个 .a 文件聚合为一个.命令如下:
I try to aggregate multiple .a files into a single one. The command is the following:
TARGET=libnumpy.a
DIR=build/lib.linux-x86_64-2.6/numpy
FILES=$(DIR)/core/_sort.a $(DIR)/core/multiarray.a $(DIR)/core/umath.a $(DIR)/core/scalarmath.a $(DIR)/core/umath_tests.a $(DIR)/core/multiarray_tests.a $(DIR)/lib/_compiled_base.a $(DIR)/numarray/_capi.a $(DIR)/fft/fftpack_lite.a $(DIR)/linalg/lapack_lite.a $(DIR)/random/mtrand.a
all:
ar cr $(TARGET) $(FILES)
但是生成的库 libnumpy.a 无法使用.尝试用它编译某些东西时,我得到
But the resulting library libnumpy.a is unusable. When trying to compile something with it, I get
libnumpy.a: could not read symbols: Archive has no index; run ranlib to add one
(我尝试运行ranlib,但没有解决问题)
(I tried to run ranlib but it didn't solve the problem)
在做 nm libnumpy.a 时我得到
When doing nm libnumpy.a I get
nm: _sort.a: File format not recognized
nm: multiarray.a: File format not recognized
nm: umath.a: File format not recognized
nm: scalarmath.a: File format not recognized
nm: umath_tests.a: File format not recognized
nm: multiarray_tests.a: File format not recognized
nm: _compiled_base.a: File format not recognized
nm: _capi.a: File format not recognized
nm: fftpack_lite.a: File format not recognized
nm: lapack_lite.a: File format not recognized
nm: mtrand.a: File format not recognized
这是怎么回事?
推荐答案
正如@Mat 提到的:
As @Mat mentioned:
#ar x <archivefile> / * Repeat for all archives */
#ar cv <all Obj fiels>
这篇关于聚合静态库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!