2013-03-21 164 views
0

我尝试使用下面的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)当rapidxml + dove.hpp只有大约150K时,输出dove.o是巨大的(19MB!),并且2)最终的libdove.a或dove.o都不可用物体:

[[email protected] dove]$ nm dove.o 
nm: dove.o: File format not recognized 
[[email protected] dove]$ nm libdove.a 
nm: dove.o: File format not recognized 

[... in other project...] 
[[email protected] 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 

回答

0

啊,明显的错误。我试图编译一个头文件,然后将它打包为一个库。虽然预编译头文件为is possible,但在此目录中完全不需要makefile