简体   繁体   中英

possible error in make file(UBuntu)

TARGETS = client server

CL_OBJ = clientMain.o Controller.o UI.o List.o Movie.o Server.o Serializer.o
SV_OBJ = serverMain.o ServerControl.o Storage.o List.o Movie.o Serializer.o

server: $(SV_OBJ) Connection.o
    g++ -o server $(SV_OBJ) Connection.o

client: $(CL_OBJ) Connection.o
    g++ -o client $(CL_OBJ) Connection.o

clientMain.o:   clientMain.cc
    g++ -c clientMain.cc

serverMain.o:   serverMain.cc
    g++ -c serverMain.cc

Controller.o:   Controller.cc Controller.h 
    g++ -c Controller.cc

UI.o:   UI.cc UI.h 
    g++ -c UI.cc

List.o: List.cc List.h
    g++ -c List.cc

Movie.o:    Movie.cc Movie.h Data.h
    g++ -c Movie.cc

Server.o:   Server.cc Server.h Movie.h Data.h
    g++ -c Server.cc

Storage.o:  Storage.cc Storage.h Movie.h Data.h
    g++ -c Storage.cc

ServerControl.o:    ServerControl.cc ServerControl.h Data.h
    g++ -c ServerControl.cc

Serializer.o:   Serializer.cc Serializer.h
    g++ -c Serializer.cc

clean:
    rm -f $(CL_OBJ) $(SV_OBJ) client server

this makefile only produces server executable not client one. It's probably at the top part before client target because it produces client file if it switches the place with server target. I'm not sure what could be the culprit and appreciate much for your help.

Make always builds the first target in the makefile by default, and only that target. If you run make client it will build client .

Or you can introduce a new target as the first one, that depends on the ones you normally want to build; before your server target add:

.PHONY: all
all: server client

You just need to add a dummy target at the beginning:

all: $(TARGETS)

This will then make all the default target when you type make on its own (ie without specifying a target) and this will then result in both client and server being built.

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