0

我有以下 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. 

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

生成文件 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)

生成文件2

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

**制作文件3

# 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
4

1 回答 1

0

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

如果要将源代码集成到主构建过程中,则必须符合它们的结构。

你有

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

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

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

于 2013-02-22T21:35:37.287 回答