繁体   English   中英

另一个makefile创建的目标“无规则可目标”

[英]“no rule to make target” for target created by another makefile

主要的makefile是这个,您可以看到它在子目录中调用了另外两个makefile: commbc

我知道我不会像立即处理所有cpp文件那样使用makefile快捷方式,但请不要马上注意这一点。

comm/makefile有一个规则可以制作comm/build/Communication.o但是我不知如何将这一事实告诉主makefile。

CPPFLAGS=-g -c --std=c++11 -Iinc -I/usr/include -I/usr/include/qt5 -I/usr/include/qt5/QtCore -I/usr/include/boost -Ibc/inc -Icomm/inc
LDFLAGS=-g -L/usr/lib/x86_64-linux-gnu/ -lQt5Core -lboost_system -lpthread  -lboost_thread 

all: comm/bin/party bc/bin/bctest bin/protocol

comm/bin/party:
    cd comm && $(MAKE)

bc/bin/bctest:
    cd bc && $(MAKE)

bin/protocol:build/main.o \
             build/TrustedParty.o \
             build/Player.o \
             build/utils.o \
             comm/build/Communication.o \
             comm/build/FileParser.o \
             comm/build/Party.o \
             comm/build/PeerConnection.o \
             comm/build/ServerModule.o \
             comm/build/Utilities.o \
             bc/build/BooleanCircuit.o \
             bc/build/Gate.o \
             bc/build/Wire.o
    g++ -Wall $^ -o bin/protocol $(LDFLAGS)


build/main.o:src/main.cpp
    g++ $(CPPFLAGS) -fPIC  src/main.cpp -o build/main.o

build/TrustedParty.o:src/TrustedParty.cpp
    g++ $(CPPFLAGS) src/TrustedParty.cpp -o build/TrustedParty.o  

build/Player.o:src/Player.cpp
    g++ $(CPPFLAGS) src/Player.cpp -o build/Player.o

build/utils.o:src/utils.cpp
    g++ $(CPPFLAGS) src/utils.cpp -o build/utils.o

clean:
    rm -fr build/* bin/*
    rm -fr comm/build/* bin/*
    rm -fr bc/build/* bin/*

当我运行make返回

16:15:03 **** Build of configuration Default for project bmr ****
make all 
g++ -g -c --std=c++11 -Iinc -I/usr/include -I/usr/include/qt5 -I/usr/include/qt5/QtCore -I/usr/include/boost -Ibc/inc -Icomm/inc -fPIC  src/main.cpp -o build/main.o
g++ -g -c --std=c++11 -Iinc -I/usr/include -I/usr/include/qt5 -I/usr/include/qt5/QtCore -I/usr/include/boost -Ibc/inc -Icomm/inc src/TrustedParty.cpp -o build/TrustedParty.o  
g++ -g -c --std=c++11 -Iinc -I/usr/include -I/usr/include/qt5 -I/usr/include/qt5/QtCore -I/usr/include/boost -Ibc/inc -Icomm/inc src/Player.cpp -o build/Player.o
g++ -g -c --std=c++11 -Iinc -I/usr/include -I/usr/include/qt5 -I/usr/include/qt5/QtCore -I/usr/include/boost -Ibc/inc -Icomm/inc src/utils.cpp -o build/utils.o
make: *** No rule to make target `comm/build/Communication.o', needed by `bin/protocol'.  Stop.

16:15:11 Build Finished (took 7s.821ms)

假设comm/Makefile知道如何正确构建该目标( comm目录中的make build/Communication.o有效); 那么如果您真的想使它正常工作(并且您可能不想这样做,请参阅递归使之被认为有害 ),您需要告诉顶层在这种情况下该怎么做。

像这样:

comm/build/%.o:
    @$(MAKE) -C comm $(patsubst comm/%,%,$@)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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