我正在尝试使用以下生成文件制作一个简单的存档:
INC :=-Ilibs/rapidxml-1.13
all:
$(CXX) -c $(INC) -o dove.o dove.hpp
ar rvs libdove.a dove.o
ranlib libdove.a
clean:
rm -f dove.o libdove.a
dove.hpp 文件有#include "rapidxml.hpp"
,你可以看到我在编译时指向一个特定的 rapidxml。目标运行完成,但 1)当 rapidxml+dove.hpp 只有大约 150K 时,make all
输出 dove.o 很大(19MB!),2)最终的 libdove.a 或 dove.o 似乎都不是可用的对象:
[hamiltont@4 dove]$ nm dove.o
nm: dove.o: File format not recognized
[hamiltont@4 dove]$ nm libdove.a
nm: dove.o: File format not recognized
[... in other project...]
[hamiltont@4 dove]$ g++ -o bin/AntHybrid build/*.o -L/home/hamiltont/foobar/dove -ldove
/home/hamiltont/foobar/dove/libdove.a: could not read symbols: Archive has no index; run ranlib to add one
collect2: ld returned 1 exit status