无法在make文件中包含库

时间:2013-02-22 19:46:12

标签: c++ c linux makefile

我有以下3个makefile,这是由其他程序员生成的。我已将我的代码包含在我标记为开头和结尾的代码之间。该代码旨在包含libspatial索引库。另一个程序员具有层次结构根目录----> tools ---> r

MakeFile1对应r,MakeFile2对应工具,MakeFile3对应root

现在,当我包含库时,我收到错误

make all 
make: *** No rule to make target `bin//home/NP/rtree/spatialindex-src-1.8.0/src/storagemanager/DiskStorageManager.cc', needed by `bin/rdf3xload'.  Stop. 

我无法理解我犯了什么错误。有人可以帮助我。

MakeFile 1

src_tools_r:=               \
    tools/r/r.cpp       \
    tools/r/Sorter.cpp      \
    tools/r/StringLookup.cpp    \
    tools/r/TempFile.cpp      \
    /home/NP/rtree/spatialindex-src-1.8.0/src/storagemanager/DiskStorageManager.cc

#Code which I wrote in order to include my library --begin
# for CS machines
COURSE_DIR = /home/NP/rtree/spatialindex-src-1.8.0/.libs
LIB_DIR     = /usr/local/lib

CPPFLAGS        = -I. \
                  -I$(COURSE_DIR)

LDFLAGS         = -L. \
                  -L$(COURSE_DIR) \
                  -R $(LIB_DIR):$(COURSE_DIR)

LDLIBS          = -lspatialindex
#Code which I wrote in order to include my library --end    

$(PREFIX)r$(EXEEXT): $(addprefix $(PREFIX),$(src_tools_r:.cpp=$(OBJEXT)) $(src_infra:.cpp=$(OBJEXT)) $(src_rts:.cpp=$(OBJEXT)) $(src_cts:.cpp=$(OBJEXT)))
    $(buildexe)

MakeFile2

include tools/r/MakeFile1

src_tools:=             \
    $(src_tools_r)      \

#Code which I wrote in order to include my library --begin
# for CS machines
COURSE_DIR = /home/NP/rtree/spatialindex-src-1.8.0/.libs
LIB_DIR     = /usr/local/lib

CPPFLAGS        = -I. \
                  -I$(COURSE_DIR)

LDFLAGS         = -L. \
                  -L$(COURSE_DIR) \
                  -R $(LIB_DIR):$(COURSE_DIR)

LDLIBS          = -lspatialindex
#Code which I wrote in order to include my library --end

** MakeFile3

# Include platform dependent makefiles
ifeq ($(OS),Windows_NT)
include Makefile.nt
else
include Makefile.unix
endif

PREFIX:=bin/

#############################################################################
# Default target
all: $(PREFIX)rd$(EXEEXT) $(PREFIX)r$(EXEEXT) $(PREFIX)rq$(EXEEXT) $(PREFIX)ru$(EXEEXT) $(PREFIX)re$(EXEEXT) $(PREFIX)ro$(EXEEXT)

#############################################################################
# Collect all sources


ifeq ($(LINEEDITOR),1)
src_lineeditor:=lineeditor/LineInput.cpp lineeditor/LineEditor.cpp lineeditor/Terminal.cpp lineeditor/Display.cpp lineeditor/Buffer.cpp
endif

include tools/Make2


source:=$(src_cts) $(src_infra) $(src_rts) $(src_tools) $(src_lineeditor)

#############################################################################
# Dependencies

generatedependencies=$(call nativefile,$(PREFIX)makeutil/getdep) -o$(basename $@).d $(IFLAGS) $< $(basename $@)$(OBJEXT) $(genheaders) $(GENERATED-$<)

ifneq ($(IGNORE_DEPENDENCIES),1)
-include $(addprefix $(PREFIX),$(source:.cpp=.d)) $(addsuffix .d,$(basename $(wildcard $(generatedsource))))
endif

#############################################################################
# Compiling

#Code which I wrote in order to include my library --begin
# for CS machines
COURSE_DIR = /home/NP/rtree/spatialindex-src-1.8.0/.libs
LIB_DIR     = /usr/local/lib

CPPFLAGS        = -I. \
                  -I$(COURSE_DIR)

LDFLAGS         = -L. \
                  -L$(COURSE_DIR) \
                  -R $(LIB_DIR):$(COURSE_DIR)

LDLIBS          = -lspatialindex



compile=$(CXX) -c $(TARGET)$(call nativefile,$@) $(CXXFLAGS) $(CXXFLAGS-$(firstword $(subst /, ,$<))) $(IFLAGS) $(IFLAGS-$(firstword $(subst /, ,$<))) $(call nativefile,$<)

$(PREFIX)%$(OBJEXT): %.cpp $(PREFIX)makeutil/getdep$(EXEEXT)
    $(checkdir)
    $(generatedependencies)
    $(compile)

#############################################################################
# Cleanup

clean:
    find bin -name '*.d' -delete -o -name '*.o' -delete -o '(' -perm -u=x '!' -type d ')' -delete

#############################################################################
# Executable

$(PREFIX)query: $(addprefix $(PREFIX),$(source:.cpp=$(OBJEXT)))

#Code which I wrote in order to include my library --end

1 个答案:

答案 0 :(得分:0)

如果这是一个独立的库,它应该有自己的Makefile,也应该单独构建。

如果要将源集成到主构建过程中,则必须符合其结构。

你有

  • 不同的c ++源后缀.cc vs .cpp
    通过将源文件重命名为.cpp,可以轻松解决此问题。
  • 绝对路径/home/NP/rtree/...与相对路径tools/r/...
    这将涉及将整个树移动到主构建树中,因为规则期望可以从那里访问目录。

但我认为最好的是拥有一个库Makefile并将其集成到主构建中。

不幸的是,没有简单的答案,如更改变量X和移动第Y行。我建议,与您的同事坐下来一起解决此Makefile问题。