我正在尝试使用以下makefile创建一个简单的存档:
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。 make all
目标运行完成,但1)输出dove.o是庞大的(19MB!)当rapidxml + dove.hpp只有大约150K,而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