简体   繁体   中英

makefile for multiple files not working

I have multiple cpp files .i have a make file a makefile for compilation, but when i make all it gives me nothing to do

CC=g++
PWD=`pwd`
ARCH=$(shell uname -s)
CFLAGS=-Wall -g -fPIC

LIBSOURCES=./libsrc/Backup/BackupLib.cpp \
./libsrc/Backup/BackupBase.cpp \
./libsrc/Backup/TransferManager.cpp

LIBOBJECTS:=$(LIBSOURCES:.cpp=.o) 

INCLUDE= -I /usr/include/libxml2/ -I ./System/ -I ./SubSystem/Queue/ -I ./System/Threads/ -I ./ -I 

./SubSystem/DB/ -I ./Controller/ -I ./SubSystem/Watcher/

MYDEFINE=-D__LINUX__ -D__cplusplus -D__CLEARCACHE__ 

LIBFLAG=-shared -Wl

LDFLAGS=-ldl -lpthread -lsqlite3 -lcrypto -lssl -lxml2 -L ./lib/ -lBackupLib 

LDLIBFLAGS=-ldl -lpthread -lsqlite3 -lcrypto -lssl -lxml2  

all:    $(LIBSOURCES) $(LIBCOMPBKUP)    

$(LIBCOMPBKUP): $(LIBOBJECTS)
    $(CC) $(CFLAGS) $(LIBOBJECTS) $(INCLUDE) $(MYDEFINE) -I ./libsrc/Backup/ -o $@

.cpp.o:
    $(CC) $(CFLAGS) $(INCLUDE) $(MYDEFINE) -I ./libsrc/Backup/ ./$< -c -o ./$@

The output of make all cmd is make: Nothing to be done for `all'

I see no definition of LIBCOMPBKUP .

So, the all target expands to:

all:  ./libsrc/Backup/BackupLib.cpp ./libsrc/Backup/BackupBase.cpp ./libsrc/Backup/TransferManager.cpp

and make rightly concludes there's nothing to do.

Your all target should just depend solely on $(LIBCOMPBKUP) (once you correctly define it), and things should start working from there.

You need a line like:

LIBCOMPBKUP = BackupLib.so

or similar so that your rule to build $(LIBCOMPBKUP) has some meaning.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM