I've a created a make file to buid a project with multiple folders, multiple libraries. When I perform a full rebuid (i.e. deleting any previous objects and outputs) everything goes well. But if I modify one of the dependencies... it gets compiled (so far so good), the librari is moved to the rightplace, but then thelinker says "undefined reference to..."
many symbols of this modified lib. I have checked also that the order I put the libraries in the listing of libraries actually matters and I get more or less errors like the one mentioned. What I'm doing wrong? Thank you!!! I'm omitting here the building of the dependencies for simplicity.
#===== aliases =====
#--- compiler
CC:=g++
CFLAGS:=-g -Wall -ansi
KDEBUG:=0
APNAME:=MyApp
OBJS:=$(wildcard *.o)
#--- folders
MAINPATH:=/home/entity-k/KLABS/AppFolder
#MAINPATH:=.
SRCDIR:=$(MAINPATH)/src
EXEDIR:=$(MAINPATH)/bin
OBJDIR:=$(MAINPATH)/obj
LIBDIR:=$(MAINPATH)/lib
#--- output file
OUTPUT:=$(EXEDIR)/$(APNAME)
#--- include folders
INCLUDES = -I $(SRCDIR)/include
INCLUDES += -I $(SRCDIR)/kMath
INCLUDES += -I $(SRCDIR)/kStd
INCLUDES += -I $(SRCDIR)/kRTLib
INCLUDES += -I $(SRCDIR)/kSimCore
INCLUDES += -I $(SRCDIR)/kEXE
INCLUDES += -I $(SRCDIR)/NetIFC
INCLUDES += -I $(SRCDIR)/kEOM
INCLUDES += -I $(SRCDIR)/kFCS
INCLUDES += -I $(SRCDIR)/kPwrP
#--- List of dependencies
KSTD_LIB:= $(LIBDIR)/kstd.a
KMATH_LIB:= $(LIBDIR)/kmath.a
KRT_LIB:= $(LIBDIR)/krtlib.a
KSIMCORE_LIB:= $(LIBDIR)/ksimcore.a
KEXE_LIB:= $(LIBDIR)/kexe.a
KEOM_LIB:= $(LIBDIR)/keom.a
KNETIFC_LIB:= $(LIBDIR)/netifc.a
KPWRP_LIB:= $(LIBDIR)/kpwrp.a
KFCS_LIB:= $(LIBDIR)/kfcs.a
MAINOBJ:= $(OBJDIR)/main.o
MAIN_DEPENDS = $(MAINOBJ) $(KSTD_LIB) $(KMATH_LIB) $(KRT_LIB) $(KSIMCORE_LIB) $(KEXE_LIB)
MAIN_DEPENDS += $(KEOM_LIB) $(KPWRP_LIB) $(KFCS_LIB) $(KNETIFC_LIB)
LIBRARIES:= -lkeom -lksimcore -lkrtlib -lkmath -lkstd -lkexe -lrt -lnetifc -lkfcs -lkpwrp
#--- directives
vpath %.h ../include
ifeq ($(KDEBUG),1)
VERBOS:= -Xlinker --verbose
else
VERBOS:=
endif
all: $(OUTPUT)
#--- Clean tool ---
clean:
-rm $(OBJDIR)/*.o
-rm -R *.o
-rm $(OBJDIR)/*.a
-rm -R *.a
-rm $(EXEDIR)/*
-rm $(LIBDIR)/*.a
@echo all object file deleted, executable deleted
#--------- Build the main app executable -------------
$(OUTPUT): $(MAIN_DEPENDS)
@+echo
@echo "===== Linking the App - Full Build ====="
@$(CC) $(CFLAGS) $(VERBOS) -o $(OUTPUT) $(OBJDIR)/main.o -L$(LIBDIR) $(LIBRARIES)
@echo "Application build successfull. "
@+echo